[Pkg-javascript-commits] [backbone] 181/281: Fixes #811 -- allow you to pass a context when unbinding events as well.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:02:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9.0
in repository backbone.
commit a49bb4f3e19b34dfcf34afa1050b934d6b6b13b4
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Thu Jan 12 17:09:15 2012 -0500
Fixes #811 -- allow you to pass a context when unbinding events as well.
---
backbone.js | 13 +++++++------
test/collection.js | 4 ++--
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/backbone.js b/backbone.js
index 5ffae25..f2d2161 100644
--- a/backbone.js
+++ b/backbone.js
@@ -82,10 +82,10 @@
return this;
},
- // Remove one or many callbacks. If `callback` is null, removes all
- // callbacks for the event. If `ev` is null, removes all bound callbacks
- // for all events.
- unbind : function(ev, callback) {
+ // Remove one or many callbacks. If `context` is null, removes all callbacks
+ // with that function. If `callback` is null, removes all callbacks for the
+ // event. If `ev` is null, removes all bound callbacks for all events.
+ unbind : function(ev, callback, context) {
var calls, node, prev;
if (!ev) {
this._callbacks = null;
@@ -95,9 +95,10 @@
} else if (node = calls[ev]) {
while ((prev = node) && (node = node.next)) {
if (node.callback !== callback) continue;
+ if (context && (context !== node.context)) continue;
prev.next = node.next;
node.context = node.callback = null;
- break;
+ // break;
}
}
}
@@ -582,7 +583,7 @@
if (this == model.collection) {
delete model.collection;
}
- model.unbind('all', this._onModelEvent);
+ model.unbind('all', this._onModelEvent, this);
},
// Internal method called every time a model in the set fires an event.
diff --git a/test/collection.js b/test/collection.js
index e6befb5..c08fa2b 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -319,7 +319,7 @@ $(document).ready(function() {
e.destroy();
ok(colE.length == 0);
ok(colF.length == 0);
- equals(null, e.collection);
+ equals(undefined, e.collection);
});
test("Colllection: non-persisted model destroy removes from all collections", function() {
@@ -330,7 +330,7 @@ $(document).ready(function() {
e.destroy();
ok(colE.length == 0);
ok(colF.length == 0);
- equals(null, e.collection);
+ equals(undefined, e.collection);
});
test("Collection: fetch", function() {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list