开发者

Ajax for Rails 3 : onchange

The below code renders the *.js.erb file and updates the display div when hit on the Display button. but it doesn't render the *.js.erb file onchange 开发者_运维百科of the dropdown, it only renders the *.html.erb. any idea?

<%= form_tag monitors_path, :id => 'monitor',:method => :get, :remote => true do %>
    <%= collection_select(:monitor, :job_id, Job.all, :id, :name, options ={:prompt => "Select a Run"}, {:onchange => "$('monitor').submit()"} ) %>
    <%= submit_tag 'Display' %>
<% end %>
<div id="display"></div>

Thanks, Volkan


this worked but not sure if it's the best solution for rail 3.

{:onchange => remote_function(:method => :get, :url => {:action => 'index'}, :with => 'Form.Element.serialize(this)')}


Edit: From this article:

Change $('monitor').submit() to $(this).parents('form:first').submit();.

Running out of ideas. :)


2nd (bad) answer:

Edit: Actually, shouldn't it be $('#monitor') instead of $('monitor')?


Previous (bad) answer:

Try this: in {:onchange => "$('monitor').submit()"} add ; return false after submit().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜