Rails 3: Link_to :remote => true with JQuery?
Posted
by
Derek
on Stack Overflow
See other posts from Stack Overflow
or by Derek
Published on 2011-11-07T01:46:13Z
Indexed on
2011/11/26
9:53 UTC
Read the original article
Hit count: 187
ruby-on-rails-3
Question update:
I have figured out that importing JQuery (even without using it at all) is causing :remote => true
to not work properly. I get the following error in the Chrome console:
Uncaught TypeError: Object [object Object] has no method 'dispatchEvent' (prototype.js:5653)
And when the link is clicked, it throws the same error again before redirecting.
Responder.erb.html
<ul>
<% @choices.each_with_index do |choice, index| %>
<li><%= link_to choice, { :action => "submit_response", :id => @id, :response => index }, :remote => true %></li>
<% end %>
</ul>
Example generated HTML:
<ul>
<li><a href="/poller/submit_response/yni?response=0" data-remote="true">True</a></li>
<li><a href="/poller/submit_response/yni?response=1" data-remote="true">False</a></li>
</ul>
© Stack Overflow or respective owner