There are a couple of frameworks that I know of that are exactly designed with this in mind
Backbone: http://documentcloud.github.com/backbone/ Knockout: http://knockoutjs.com/ On 1 December 2011 11:34, Jarek Foksa <[email protected]> wrote: > I have following object: > > var person = { > firstName: 'John', > lastName: 'Smith', > } > > The object is coupled with DOM tree which looks like this: > > <div class="person"> > <div data-type="firstName">John</div> > <div data-type="lastName">Smith</div> > <div> > > > Any change done to the object (added, deleted, modified property) > should result in the same change being done > to DOM tree. And the opposite: any change done to DOM tree should > result in the same change being done to the object. > > It's easy to keep the object in sync with DOM nodes, I just attach a > bunch of event listeners to nodes and the object > is updated by callback when event fires. > > But how do I keep DOM nodes in sync with object? Is there a way to > watch object for changes and fire a callback when object's > property is modified/added/removed? > > Is there a framework that could make this task easier? > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- Pete Otaqui [email protected] +44 7949 945542 -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
