Canjs Live Binding

canjs

http://www.slideshare.net/StanCarrico/milwaukee-js-live-binding-with-canjs - done reading

What is live binding?

Change in the data model will automatically update the UI, and change in the UI by user will automatically update the data model.

What is opt-in data binding?

Although can.ejs’s live-binding is super fast, setting up live data binding can be too slow in certain situations (like rendering a list of 1000 items). EJS’s live binding is opt-in. It only turns on if you are using the attr method. If the following template binds to a todo's name …

<li> <%= todo.attr('name') %> </li>

… the following doesn’t setup live-binding and renders much faster …

<li> <%= todo.name %> </li>

I am not sure exactly what this means yet.

How to implement live binding on a form element?

<input type=‘text’ value=‘<%= coffee.attr(“roaster”) %>’ />

I wonder how this EmbeddedJS stuff works. The above is just an EmbeddedJS template. After it is evaluated, the resulted string probably contains an even handler for the onchange event.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License