Hacker Newsnew | comments | ask | jobs | submitlogin
jacobr 582 days ago | link | parent

Can you explain how templates make data binding easier? Working with the DOM means that you immediately can save a reference to an element, rather than generating the HTML and then traversing that HTML to get the element you want to change.


jakejake 582 days ago | link

It's kinda a different technique altogether. Instead of writing code to respond to changes and then update specific DOM elements, you just create a template that has usually some kind of template variables/placeholders that the template engine will populate with data.

Then you "bind" that to some kind of object. Whenever the object changes, the framework then re-renders the template. So the effect is that when your model changes all of your UI components on the page just magically refreshes themselves.

Probably not the best explanation, but hopefully makes sense!

-----




Lists | RSS | Bookmarklet | Guidelines | FAQ | DMCA | News News | Feature Requests | Bugs | Y Combinator | Apply | Library

Search: