Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Tracker - CanJS Plugin For Two-way Binding

$
0
0
Awesome work!  You might make it even easier to setup if you're in an EJS flie like:

can.EJS.Helpers.prototype.input = function(obs, attr, props){
  return "<input "+can.view.hook(function(el){
    el.value = obs.attr(attr)
    var func = function(ev, newVal){
      el.value = newVal
    }
    obs.bind(attr, func)
    can.bind.call( can.$(el), "destroyed", function(){
      obs.unbind(attr, func)
    })
  })+"/>"
}


<%== input(person,"name") %>


You could hook in Tracker to this somehow.

Viewing all articles
Browse latest Browse all 3491

Trending Articles