Live Binding
can.mustache.Binding
Live binding refers to templates which update themselves as the data used in the mustache tags change.
Live binding refers to templates which update themselves as the data used in the mustache tags change.
It's very common as the page is interacted with that the underlying data represented in the page changes. Typically, you have callbacks in your AJAX methods or events and then update the content of your controls manually.
In this example, we have a simple user welcome screen.
The template evaluates the
messages
and adds the hooks for live binding automatically. Since we have no message it will render:Now say we have a request that updates the
messages
attribute to have5
messages. We call the attr method on the can.Map to update the attribute to the new value.After can.Map receives this update, it will automatically update the paragraph tag to reflect the new value.
For more information visit the can.Map documentation.