I am creating an application where most of the HTML is built using javascript. The DOM structure is built using some JSON data structures that are sent from the server, and then the client code creates a user interface for this data.
My current approach is to follow the JSON data structures and call the script.aculo.us Builder.node method to build the DOM structure, and then add it to some element that is actually in the HTML sent from the server, along the way I register event listeners for the various elements that need them. This provides sufficient flexibility and provides a very dynamic interface.
However, I feel that it is not very stable, because the presentation logic (i.e. the DOM structure) is so closely related to the code that processes the data, and the event handlers, and the data that is stored in memory to save state and can transmit these changes back to the server.
Are there any template solutions that will allow me to parse the DOM structure with the code that runs the application? Currently, my only dependencies in the library are prototype.js and script.aculo.us, so I would like to avoid any major libraries, but any suggestions are welcome.
Thanks!
EDIT: for some reason. What good template language is supported in Javascript? didn't appear in small search results when I entered this question. However, it appears in the "Related" sidebar.
I will read some suggestions there, and if I find a solution, I will close this question. Otherwise, I will clarify this question with the reasons why these solutions will not work for me.
source share