Backbone.js Trying to bind a callback by passing in the function throws an error
by fguillen
HTML
<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>
JavaScript
var MyView = Backbone.View.extend({
initialize: function() {
this.colorInput = $("<input />", {
"id": "color",
"name": "color",
"type": "text",
"value": "value"
});
this.colorInput.on("change", this.changeColor);
},
changeColor: function() {
alert( "changeColor event handler" );
}
});
window.M = new MyView();
window.M.colorInput.val( "other" );