Topic: Using prototype to render several partials with one round trip?
I am using rails 2.2.2 with prototype 22.214.171.124.
I currently have an unobtrusive implementation working in my view i have several areas that need to be refreshed periodically (think of these areas as widgets). Each 'widget' has a css classed assigned as 'autorefresh' which i use in the js script to gather the divs from (not all divs are getting autorefreshed). I then get the id from the div and process the update. However each of these areas are being updated by a seperate call to a specific method in the controller. Not good obviously because this requires too many round trips to the controller.
The bloated implementation looks like this from a processing perspective:
widget-a calls and recevied from WidgetsController.widget_a_xhr_autorefresh
widget-b calls and recevied from WidgetsController.widget_b_xhr_autorefresh
widget-e calls and recevied from WidgetsController.widget_e_xhr_autorefresh
Each widget is a div on the page which is presented via a partial.
Again this works now but its way too heavy for production and since ive taken an interest in front-end work lately i want to know the best-practices but cannot find anything around where this is being done.
I thought about simply calling one method in the controller that passes back all the data for all the partials. I guess this would be the 'Chunking Pattern' i read about. It would conslidate the calls down to one. My problem with this approach is how to organize the results (json?, html?) to be sent to each partial when they are rendered.
I have tried my hardest to avoid using rjs lately, im trying to go ujs as much as possible. Thanks for any help and I can post code if needed. Hopefully this makes some sense ;)