What you currently have will generate HTML that looks like the following if
you have 3 reviews:
<p id='votes'>1 vote</p>
<p id='votes'>2 votes</p>
<p id='votes'>3 votes</p>
See the problem?
The problem is that each paragraph tag has the same ID. jQuery will only
update the first one. Each paragraph needs to have a unique ID, then your
Including the primary key in the HTML ID is a good solution:
<p id="review_<%= review.id %>">
Then your jQuery can update the specific paragraph that it needs to:
$("#review_<%= review.id %>").html("<%= review.votes_count %>")
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/8XDnjkoJ3SUJ.
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to email@example.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.