I have what I think is a simple problem that I was hoping someone could
help me with. I have an application that keeps track of many
restaurants. Each restaurant has many user reviews associated with it.
When a user does a search it will return a list of restaurants. I would
like to have a "see reviews" link with each restaurant listing.
Now when someone clicks on the "see reviews" link I would like to have
the reviews appear instantly below the restaurant listing without a page
Now the way I am doing it is by pre-loading and hiding the reviews. My
partial for displaying each restaurant looks like this:
<a href="#" onClick="toggleReviews()";>See Reviews</a>
<div id=review style="display: none">
<% if !listing.reviews.blank? %>
<%= render :partial => 'review', :collection => listing.reviews %>
<% end %>
Now the problem is in my toggleReviews function I need the div id of
the element to toggle. If I use "review" it will show the reviews for
all restaurants. Any ideas how I can dynamically set the div id to
"review" + listing.review.id so that I can toogle the correct one? Or is
there a better way to accomplish what I am trying to do.