开发者

Rails 3 & Ajax date_select onchange => submit

开发者 https://www.devze.com 2023-03-17 14:10 出处:网络
I\'d like my date to get saved anytime I change my date via ajax, is this possible? I tried <%= form_for @dates开发者_StackOverflow,:remote => true do |f| %>

I'd like my date to get saved anytime I change my date via ajax, is this possible? I tried

<%= form_for @dates开发者_StackOverflow,:remote => true do |f| %>
    <%= f.date_select :booking_date,:onchange => "this.form.submit();" %>
<% end %>

but it does nothing, any good work arounds?


From the rails documentation:

date_select(object_name, method, options = {}, html_options = {})

Because onchange is an html option you need to provide an empty set of options to date_select, otherwise it assumes onchange is a date_select option.

You should change your call to date_select to look like this:

f.date_select :booking_date, {}, :onchange => "this.form.submit();"


Are you including this in your layout:

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
0

精彩评论

暂无评论...
验证码 换一张
取 消