T.js icon indicating copy to clipboard operation
T.js copied to clipboard

Data binding

Open gcao opened this issue 12 years ago • 0 comments

  • Depend on watch.js to monitor changes on object property
  • Can depend on multiple properties
  • Use default handlers to handle most common use
    • input: on change, set data property to element's value attribute; on data property change, set input's value
    • span etc: there is no change event handler; on data property change, set text

Example

T.bind($(this), data, ['prop1', 'prop2'], 
{
dataChanged: function(el){ el.val(data.prop1 + data.prop2); }, 
change: function(){ data.prop1 = el.val(); }
})

gcao avatar Oct 02 '13 13:10 gcao