這是我在我的erb.js文件....但它不工作:如何從rails 3中的erb.js輸出幫助程序?
1 //Update with a message
2 $('#follow-update').html("<%= follow_button(@question) %>")
follow_button是一個幫手:
20 def follow_button(resource)
21
22 type = resource.class.name
23 follow_status = current_user.following?(resource)
24
25 verb = "Follow" if follow_status == false
26 verb = "Unfollow" if follow_status == true
27
28 content_tag(:div, :class => "follow-button") do
29 link_to "#{verb} this #{type} ", follow_path(:followed_type => type,
30 :followed_id => resource.id,
31 :follow_verb => verb),
32 :class => "button",
33 :remote => true
34 end
35 end
36 end
助手單機工作正常,但我想讓它更新我的按鈕。也許有一種方法可以在不更換整個幫手的情況下更新文本?
嗯......好吧我只是改變了按鈕文字,到目前爲止好...可能需要刪除這.... .... – Angela 2011-04-30 04:57:19
nope,我確實需要它重新顯示助手,因爲邏輯需要再次運行.... – Angela 2011-04-30 05:01:40