How do I add a custom method to a backbone model?
I've tried:
initialize: function() {
var func = function() {
//do some stuff with the model
}
_.bind(func, this)
}
and
initialize: function() {
var func = function() {
//do some stuff with the model
}
this.on("func", func, this);
}
However in both cases:
myModelInstance.func(); //object has no method func
I'd prefer not to use _.bindAll().
No comments:
Post a Comment