Targeting row when responding with js rails
- by berto77
I have an application where a user can vote on reviews. They can vote up or down. Now when there's a listing of reviews, I have a problem targeting the review the user voted on.
I'm using a respon_to block in my rails controller and responding with js. So for instance, I have a vote_up method, and a vote_up.js.erb template. in that template, I have the following:
var id = $('article.comment').attr('id').split('_')[1];
alert("id: " + id);
$('.votecomment_' + id).find('.score').html("<%= @review2.vote_total %>");
I'm just alerting the id. The problem is that the id always returns the value of the first review found on the page. How can I pass the context aka this, to javascript, so I can figure out which review to target?