Skip to content

Instantly share code, notes, and snippets.

@ryugoo
Last active December 21, 2015 16:19
Show Gist options
  • Save ryugoo/6333146 to your computer and use it in GitHub Desktop.
Save ryugoo/6333146 to your computer and use it in GitHub Desktop.
var core, Model, model;
core = Object.create(Backbone.Events);
Model = Backbone.Model.extend();
model = new Model();
core.listenTo(model, 'myEvent', function () {
console.log('Hello, World');
});
/* Case : Backbone.Events.stopListening
----------------------------------------*/
model.stopListening();
console.log(model);
model.trigger('myEvent'); // Hello, World
/* Case : Backbone.Events.off
----------------------------------------*/
model.off();
console.log(model);
model.trigger('myEvent'); // Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment