Reputation: 39
I am trying to translate this code from Prototype into the same thing in Jquery:
$("follow_form").update("<%= escape_javascript(render('users/unfollow')) %>")
$("followers").update('<%= "#{@user.followers.count} followers" %>')
Upvotes: 1
Views: 41
Reputation: 414086
I think you'd want:
$('#follow_form').html("<%= escape_javascript(render('users/unfollow')) %>");
$('#followers').html('<%= "#{@user.followers.count} followers" %>');
The Prototype "$" function is a short-cut to "document.getElementById()" (sort-of; it's a little more complicated on IE). For jQuery, you have to use a CSS-like selector syntax. Then, the ".update()" function in Prototype is for accessing "innerHTML" with some extra cleanup behavior, and jQuery's ".html()" is similar.
Upvotes: 6