Learning rails and AJAX. How do I load a div via ajax and then toggle hiding/showing it?
Posted
by Kevin L.
on Stack Overflow
See other posts from Stack Overflow
or by Kevin L.
Published on 2010-04-23T19:22:14Z
Indexed on
2010/04/23
19:23 UTC
Read the original article
Hit count: 223
I'm doing my first Ruby on Rails project. I am working on a project where the user can add a new message. Then they can add updates to this message like a thread. I've got it all written and now I'm going back and applying some AJAX. I want to show just the main message when the page first loads. Then when I click a link I want an AJAX event to fire that populates a div with all the updates to the message. Then I want this same link to toggle hiding and showing the div.
I've made a submit button to fire the ajax and get back the updates using form_remote_tag. I've also created a separate link to toggle the hiding using $(div_id).toggle();. But now I'm stuck on how to combine these two things into one all purpose link.
Thanks.
© Stack Overflow or respective owner