From 09044c4d62c734d369eade0659335b628c4dacc9 Mon Sep 17 00:00:00 2001 From: Jmeas Date: Thu, 22 May 2014 00:05:20 -0400 Subject: [PATCH] Adds docs for unbindEntityEvents Resolves #1223 --- docs/marionette.functions.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/marionette.functions.md b/docs/marionette.functions.md index 6ab3c5e674..56607fc730 100644 --- a/docs/marionette.functions.md +++ b/docs/marionette.functions.md @@ -147,6 +147,36 @@ The third parameter is a hash of { "event:name": "eventHandler" } configuration. Multiple handlers can be separated by a space. A function can be supplied instead of a string handler name. +## Marionette.unbindEntityEvents + +This method can be used to unbind callbacks from entities' (collection/model) events. It's +the opposite of bindEntityEvents, described above. Consequently, the APIs are identical for each method. + +```js +// Just like the above example we bind our model events. +// This time, however, we unbind them on close. +Backbone.View.extend({ + + modelEvents: { + "change:foo": "doSomething" + }, + + initialize: function(){ + Marionette.bindEntityEvents(this, this.model, this.modelEvents); + }, + + doSomething: function(){ + // the "change:foo" event was fired from the model + // respond to it appropriately, here. + }, + + onClose: function() { + Marionette.unbindEntityEvents(this, this.model, this.modelEvents); + } + +}); +``` + ## Marionette.normalizeMethods Receives a hash of event names and functions and/or function names, and returns the