简体   繁体   中英

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:

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?

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

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM