I am working on an AJAXy project (Dojo and Rails, if that matters). There are several places where the user should be able to sort, group and filter the results. There are also places where the user fills out a short form, and the resulting item is added to the list on the same page.
The non-AJAXy implementation works fine - the level-level server already knows how to display this stuff, so it can simply do it again in a different order or with an additional element. This, however, adds a lot of load to the server.
So, we switched to sending JSON from the server and did a lot of (re) rendering on the client side. The downside is that now we have duplicate code for rendering each page: once in Rails, which was created for this, and once in Dojo, which was not there. The latter is just a string concatenation.
So, the first question is: is there a good MVC Javascript structure that we could use to make client-side rendering more convenient?
And the second question: is there a way to generate client-side views in Javascript and server-side views in ERB from the same template? I think pragmatic programmers did it.
Alternatively, the question is part three: am I completely missing the other corner? Maybe send JSON from the server, but also include the HTML snippet as an attribute so that Javascript can do filtering, sorting, etc., and then just paste this snippet?
source
share