[英]how to use link_to with ajax in rails 3.2.1
I m using Rails 3.2.1 . 我正在使用Rails 3.2.1 。 how to use link_to with remote=>true
如何将link_to与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 在我的new.html.erb文件中
<%= link_to "click here", {:action=>"clickme"}, {:remote => true, :id=>"clk"} %>
<div id="allclick">
<%= render :partial => 'goclick' %>
</div>
_goclick.html.erb _goclick.html.erb
<%= @clk %>
clickme.js.erb 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:
但是当我检查Firebug控制台时,它显示了我:
$("allclick").update("you click me");
In My application.js 在我的application.js中
//= require jquery
//= require jquery_ujs
Help Me :( 帮我 :(
尝试使用html
而不是update
:
$("#allclick").html("<%= escape_javascript(render(:partial => "goclick")) %>");
使用$(“#allclick”)而不是$(“ allclick”),您错过了“#”;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.