ruby on rails: submit a form clicking a check_box using JQuery

ⅰ亾dé卋堺 提交于 2020-01-05 03:24:45

问题


I have a form. I added a JQuery onchange submit to the number_field tag. The same i want to do for the check_box_tag. I want that the form get submitted if you click on one checkbox. i tried many options but i don't get it. Hope you can help me.

<%= form_tag("/rooms/list", method: "get", :name => "list", :remote => true) do %>
    <%= label_tag(:size, "gewünschte Raumgröße:") %>
    <%= number_field(:room, :size, in: 0.0..999999999, step: 1.0, :value => @size, :onchange => ("javascript: document.list.submit();")) %>
    <br>
    Equipment
    <br>
    <% @categories.each do |category| %>
        <%= check_box_tag(category, {:remote => true, :onclick => ("javascript: document.list.submit();")}) %>
        <%= label_tag(category, category) %>
    <% end %>
<% end %>

回答1:


I got it!

<%= check_box_tag(category,true, false, :onclick => "javascript: document.list.submit();") %>


来源:https://stackoverflow.com/questions/27243479/ruby-on-rails-submit-a-form-clicking-a-check-box-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!