I has a view with this event:
var View = Backbone.View.extend({
el: $('#test'),
events: {
"change input": "test"
},
test: function(e) {
console.log("test");
}
});
var view = new View();
With backbone 0.9.9 it work, but with backbone 0.9.10 I got this error: Uncaught TypeError: Object [object Object] has no method 'off'. What I need to change to work with events on backbone 0.9.10?
I'm using this cdn's
http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.10/backbone-min.js
Thanks
I was using jquery 1.5.2 and the method off was introduced on jquery 1.7.0. Backbone 0.9.9 require that el contain the method unbind while Backbone 0.9.10 require that el contain the method off. The method unbind exist on jquery 1.5.2 and that was the reason why my code worked with backbone 0.9.9.
Try this...
var Test = Backbone.View.extend({
events: {
"change input": "test"
},
initialize: function() {
this.setElement($('#test'));
},
test: function(e) {
alert("test");
}
});
var test = new Test();
Or, this would be even better...
var Test = Backbone.View.extend({
events: {
"change input": "test"
},
test: function(e) {
alert("test");
}
});
var test = new Test({
el: $('#test')
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With