簡體   English   中英

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

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

我的 js.erb 文件中有以下內容,但它不執行 ruby 代碼:

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

混合 ruby (並從控制器訪問內容)和常規文本的正確方法是什么?

js.erb文件就像html.erb文件一樣工作。 您需要改用<%= %>標簽:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM