[英]How do I write a jquery js.erb to have both html and ruby output for a link_to :remote => in rails 3?
I have the following in my js.erb file, but it doesn't execute the ruby code:我的 js.erb 文件中有以下内容,但它不执行 ruby 代码:
4 //Update the number of followers
5 $('.follow-count').html("#{@followers_count} following")
What's the right way to mix both ruby (and access things from the controller) and regular text?混合 ruby (并从控制器访问内容)和常规文本的正确方法是什么?
js.erb
files work just like your html.erb
files. js.erb
文件就像html.erb
文件一样工作。 You need to use <%= %>
tags instead:您需要改用
<%= %>
标签:
$('.follow-count').html("<%= @followers_count %> following")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.