开发者

How do I write a jquery js.erb to have both html and ruby output for a link_to :remote => in rails 3?

开发者 https://www.devze.com 2023-03-01 19:00 出处:网络
I have the following in my js.erb file, but it doesn\'t execute the ruby code: 4 //Update the number of followers

I have the following in my js.erb file, but it doesn't execute the ruby code:

4 //Update the number of followers
  5 $('.follow-count').html("#{开发者_Go百科@followers_count} following")

What's the right way to mix both ruby (and access things from the controller) and regular text?


js.erb files work just like your html.erb files. You need to use <%= %> tags instead:

 $('.follow-count').html("<%= @followers_count %> following")
0

精彩评论

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