ruby on rails - How can I re-populate a list in a <div> after adding an item to it using AJAX? -


Specifically, I have several pages in the railway app that use only partial use. In the action handler for each page, I am creating an array object (e.g., @list_elements ) based on a database query. Each page uses a different query so that each page has different list elements in it. At the top of every page I have a form_remote_tag one edit field, so that the user can add a new element in a dynamic, AJAXy fashion (it seems like the Twitter 'What's happening' box).

My problem is that when the AJAX command appears to fire, I need to reload the list to add new items, but the contents of the list were determined by a database query . I should remember that which query applies to the current page (i.e. the controller action) so that I can run it again, I thought of storing something in the rail session structure, but this overkill Looks like - it's like storing the current page all the time.

Has anyone done such a thing and is a good railing, how to get it?

Ben

You can not render just partial in your RJS template ?

Page [: div_element] .replace_html: partial => 'partial'

If you query and define the array in the controller verb, then An AJAX call will refresh that array.


Comments