This is what I have in my erb.js file....but it doesn't work:
1 //Update with a message
2 $('#follow-update').html("<%= follow_button(@question) %>")
follow_button is a helper:
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
The helper stand-alone works fine, but I want it to update my button. Perhaps there's a way to just update the text without replacing the whole helper?