【发布时间】:2011-08-15 22:15:16
【问题描述】:
这是我的 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
帮助器独立工作正常,但我希望它更新我的按钮。也许有一种方法可以只更新文本而不替换整个帮助器?
【问题讨论】:
-
hmm...好吧,我只是更改了按钮文本,到目前为止还不错...可能需要删除它... :)
-
不,我确实需要它来重新显示帮助程序,因为逻辑需要再次运行......
标签: jquery ruby-on-rails helper