I have a rails layout form with multiple partials making up the page:
Layout:
Header (partial)
Left tree (partial)
Main area (partial)
When the user makes changes in the main area I want to update the left tree (which is a partial) to represent the change. I would do that with ajax but how would I use refresh it with a partial (the problem is how do I return a partial from the controller which can be used by the JQuery function).
Johann
As I see it, you have 2½ possibilities:
layout
partial if the action is requested using an xhr request.
The first option is a bit icky, but somewhat acceptable IMO. You might want to check widgets in this case as well: http://apotomo.de/
The second option is similar to the first one, but not really acceptable IMO, since you’re returning different stuff from the same “endpoint”.
The last approach seems best, but might be a bit overkill, depending on your application. Like this your controller can return JSON only and you render the view in the client. Depending on how your application is structured, you might want to have a look at a Javascript MVC solution such as Backbone as well.