rails,为什么我的页面在onchange事件处理程序后重定向

时间:2018-02-15 23:28:04

标签: ruby-on-rails ruby ajax event-handling

我有点困惑为什么会发生这种情况

<div class="col-lg-12 col-padding-helper">
      <%= form_tag product_builder_path, method: :get, remote: true, class: 'product_builder_form' do %>
      <div>
        <%= label_tag :banner_top, "Banner", class: "label-style" %>
        <%= select_tag :banner_top, options_from_collection_for_select(BannerTemplate.where(user_id: [1,current_user.id]).collect {|p| p}, 'id', 'name', params[:banner_top].to_i), class:'form-control banner-top-select', data: { remote: true }, onchange: "this.form.submit();" %>
      </div>
      <div class="col-lg-5 col-padding-helper">
        <%= label_tag 'Campaign Size' %></br>
        <%= select_tag 'type', options_for_select(['Small (4 Products)', 'Medium (7 Products)', 'Large (10 Products)' ], params[:type]), multiple: false, class: "form-control product-builder-",  data: { remote: true }, onchange: "this.form.submit();"  %>
      </div>
      <div class="col-lg-7 col-padding-helper">
        <%= label_tag 'Theme' %></br>
        <%= select_tag 'theme', options_for_select(['Default BWX Theme', 'Black Friday Theme'], params[:theme]), multiple: false, class: "form-control", onchange: "this.form.submit();" %>
      </div>
      <% end %>
    </div>

除非我在控制器中有响应阻止,否则我的假设是,当我选择某些内容时,它不应该重定向,但实际上它是重定向的。有人可以解释为什么会这样吗?

这是我的控制台:

Started GET "/product_builder?utf8=%E2%9C%93&banner_top=60&type=Medium+%287+Products%29&theme=Default+BWX+Theme&banner_top=69" for ::1 at 2018-02-15 15:21:09 -0800
Processing by CampaignsController#product_builder as JS
  Parameters: {"utf8"=>"✓", "banner_top"=>"69", "type"=>"Medium (7 Products)", "theme"=>"Default BWX Theme"}

Started GET "/product_builder?utf8=%E2%9C%93&banner_top=69&type=Medium+%287+Products%29&theme=Default+BWX+Theme" for ::1 at 2018-02-15 15:21:10 -0800
Processing by CampaignsController#product_builder as HTML
  Parameters: {"utf8"=>"✓", "banner_top"=>"69", "type"=>"Medium (7 Products)", "theme"=>"Default BWX Theme"}

因此,在JS处理之后,它后面跟着HTML。我在这里做错了什么?

谢谢

0 个答案:

没有答案