I just want to fire an event when an input changes value using jQuery 1.7.2 and Backbone.js.
Currently I have the following (which works)
MyView: Backbone.View.extend({
initialize: function() {
this.colorInput = $("<input />", {
"id": "color",
"name": "color",
"value": this.model.get("color")
});
var self = this;
this.colorInput.on("change", function() {
self.changeColor();
});
},
changeColor: function() {
var color = this.colorInput.val();
this.model.set("color", color);
}
});
I was trying to do it the other way where I just pass in my function.
this.colorInput.on("change", this.changeColor, this);
But when trying to do it that way, it throws the error
((jQuery.event.special[handleObj.origType] || {}).handle || handleObj.handler).apply is not a function
.apply( matched.elem, args );
Which I'm not able to figure out. Any ideas why this way doesn't work?
change
event, I gave up due it was not a problem related to the question. – Zenia