I receive JSON objects from a websocket with update/create/delete flags. Based on this information, I either update, create or delete HTML elements and bind callbacks. This can affect multiple HTML elements.
My current approach was to put everything into specific objects which handle HTML generation via jquery e.g.:
$.("<table>").addChild($("<tr>")).addClass('test')
and bind event listeners. But with the addition of more and more code it got really messy and now im looking for a proper way to seperate the code.
Are there any ideas on how to do this properly? Frameworks? Maybe jQuery Templates (which still leaves me in the dark on how add callbacks cleanly)?
In your case I can recommend you to have a look at Knockoutjs , AngularJS or Backbone.js.