2011-04-29 18 views
0

我在js.erb文件下面,但它不執行Ruby代碼:如何寫一個jQuery js.erb以在rails 3中爲link_to:remote =>同時輸出html和ruby輸出?

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

什麼是混合使用這兩個紅寶石(和訪問的東西從控制器)和普通文本的正確方法?

+0

$ HTML( 「<%=#{@ FOLLOWERS_COUNT}%>以下」) – 2011-04-29 14:31:58

+0

@Angela:賽義德和Dylan答案就足夠了到你的問題.. :) :) :) – 2012-10-16 09:23:27

回答

2

js.erb文件就像您的html.erb文件一樣工作。您需要使用<%= %>標籤來代替:( '後續計數')

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