I have some Backbone.js code that bind a click event to a button, and I want to unbind it after clicked, the code sample as below:
var AppView = Backbone.Vie
You could solve this another way
var AppView = Backbone.View.extend({
el:$("#app-view"),
initialize:function(){
_.bindAll(this,"cancel");
},
events:{
"click .button":"do"
},
do:_.once(function(){
console.log("do something...");
})
});
var view = new AppView();
underscore.js once function ensures that the wrapped function can only be called once.