var JavascriptHelper = Backbone.Model.extend("JavascriptHelper",
{}, // never initialized as an instance
{
myFn: function() {
$('.selector').live('click', function() {
this.anotherFn(); // FAIL!
});
},
anotherFn: function() {
alert('This is never called from myFn()');
}
}
);
通常的_.bindAll(this, ...)
方法在这里不起作用,因为我从未将此模型初始化为实例。有任何想法吗?谢谢。