mercredi 20 juin 2018

Form submit creates GET call instead of POST call in Ruby on mobile view

I have searched through various answers but none have worked for me so far. So here is my form which is working fine when I do a form submission from web view, but on mobile the form automatically does a GET call instead of POST call. However when I remove, target: :_blank, it works fine on mobile. But I need to redirect user to a new page as I change URLs when search button is clicked.

Current url: http://localhost:4000/hotels/470?website_template_id=3

NewPage url: http://localhost:4000//booking_widget/availability

The same URLs are working fine on web though.

<div class="booking-widget">
  <%= form_tag("#{Settings.host_url}/booking_widget/availability", method: :post , target: :_blank , id: :booking_search_form,:class => "form-inline reservation-horizontal clearfix")%>
    <div class="booking-area">
      <div class="booking-values">
        <h4>CHECK IN</h4>
        <input type="hidden" id="check-in" name="start_date" value="" />
        <p class="check-in"> <span><span></p>
        <div id="from"></div>
      </div>
      <div class="booking-values">
        <h4>CHECK OUT</h4>
        <input type="hidden" id="check-out" name="end_date" value="" />
        <p class="check-out"> <span><span></p>
        <div id="to"></div>
      </div>
      <div class="booking-values">
        <input type="hidden" id="rooms" name="rooms" value="1" />
        <h4>ROOMS</h4>
        <p class="rooms">1</p>
        <div class="dropdown">
          <ul id="booking_room_select">
            <%(1..@max_no_of_rooms).each do |num|%>
            <li data-value="<%=num%>"><%=num%></li>
            <%end%>
          </ul>
        </div>
      </div>
      <div class="booking-values">
        <input type="hidden" id="adults" name="adults" value="1" />
        <h4>ADULTS</h4>
        <p class="adults-click">1</p>
        <div class="adults-children">
          <div class="room-set">
            <div class="room-header">
              ROOM 1
            </div>
            <div class="room-changer">
              <div class="changers adults">
                <p>ADULTS</p>
                <input id="single_room_no_of_adults" class="form-control numbers-count" type="number" value="1" min="1" max="<%=@max_no_of_adults%>" disabled />
              </div>
              <div class="changers children">
                <p>CHILDREN</p>
                <input id="single_room_no_of_children" class="form-control numbers-count" type="number" value="0" min="0" max="<%=@max_no_of_children%>" disabled />
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="booking-values">
        <input type="hidden" id="children" name="children" value="0" />
        <h4>CHILDREN</h4>
        <p class="children-click">0</p>
      </div>
      <div class="booking-values hidden">
        <input type="hidden" name="hotel_id" value="<%=@hotel.id%>"/>
        <input type="hidden" name="currency" value="INR"/>
        <input type="hidden" name="party" id="party" value=""/>
        <input type="hidden" id="website_template_id" name="website_template_id" value="3" />
      </div>
    </div>
    <div class="booking-cta">
      <button id="booking-widget-submit" formmethod="post" type="submit">BOOK NOW</button>
    </div>
  </form>
  <div class="clearfix"></div>
</div>

My route is defined as:

post 'booking_widget/availability' => 'booking_widget#availability', :as => 'booking_availability'

Aucun commentaire:

Enregistrer un commentaire