On Feb 16, 5:28 am, vishy <[email protected]> wrote:
> I am currently working on a blog site in which each blog entry will
> have its own comments. The comments can be seen by clicking a comments
> link present at the end of each blog entry. I am using RJS to toggle
> the view of the comments.
>
> #code for the comment link and the comments form
> <div id="blog_comments"><%= link_to_remote pluralize
> (blogentry.comments.size, 'Comment'), :url => { :action =>
> 'show_comments'}%></div>
> <div id="comments">
>                 #code for comments form
> </div>
>
> #show_comments.js.rjs
> page.select("#comments").each do |element}
>      element.toggle
> end
>
> Using the above code I am able to toggle the visibility for the
> comments of all the blog entries. However what I want to do is to
> toggle the comments only for the blog entry for which the comments
> link has been clicked.
>
replace #comments with a selector that identifies only those things
you want to toggle (and you're sort of inferring you have multiple
elements on the page with the id "comments". That's not a good thing
and can produce unexpected results) and have your link to remote pass
something identifying the entry to operate on (and it looks like you
could use link_to_function rather than link_to_remote and save
yourself a server round trip)

Fred
> Any help in this regard with be greatly appreciated.
>
> Thanks,
> vishy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to