I m using Rails 3.2.1 . how to use link_to with remote=>true
My Method in Controller
def clickme
@clk = "you click me"
respond_to do |format|
format.js { render :layout=>false }
end
end
My View
In my new.html.erb file
<%= link_to "click here", {:action=>"clickme"}, {:remote => true, :id=>"clk"} %>
<div id="allclick">
<%= render :partial => 'goclick' %>
</div>
_goclick.html.erb
<%= @clk %>
clickme.js.erb
$("allclick").update("<%= escape_javascript(render(:partial => "goclick")) %>");
On my web-page everything is fine when I click on click here link nothing change. But when I check Firebug console it shows me:
$("allclick").update("you click me");
In My application.js
//= require jquery
//= require jquery_ujs
Help Me :(
尝试使用html
而不是update
:
$("#allclick").html("<%= escape_javascript(render(:partial => "goclick")) %>");
使用$(“#allclick”)而不是$(“ allclick”),您错过了“#”;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.