Tim*_* T. 5 jquery ruby-on-rails helper
这就是我在我的erb.js文件中所拥有的....但它不起作用:
1 //Update with a message
2 $('#follow-update').html("<%= follow_button(@question) %>")
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
帮助程序独立工作正常,但我希望它更新我的按钮.也许有一种方法可以在不更换整个助手的情况下更新文本?
Pie*_*rre -1
抱歉,我现在无法测试,但是您是否注意过 html 安全或 javascript 转义?
例如,尝试将您的内容包含follow_button(@question)在raw()or中escape_javascript()?
| 归档时间: |
|
| 查看次数: |
3020 次 |
| 最近记录: |