mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Rename to undelegateEvents
As suggested by @jashkenas https://github.com/documentcloud/backbone/pull/620#issuecomment-2132400
This commit is contained in:
@@ -954,7 +954,7 @@
|
||||
delegateEvents : function(events) {
|
||||
if (!(events || (events = this.events))) return;
|
||||
if (_.isFunction(events)) events = events.call(this);
|
||||
this.clearEvents();
|
||||
this.undelegateEvents();
|
||||
for (var key in events) {
|
||||
var method = this[events[key]];
|
||||
if (!method) throw new Error('Event "' + events[key] + '" does not exist');
|
||||
@@ -971,7 +971,7 @@
|
||||
},
|
||||
|
||||
// Clears all callbacks previously bound to the view with `delegateEvents`.
|
||||
clearEvents: function() {
|
||||
undelegateEvents: function() {
|
||||
$(this.el).unbind('.delegateEvents' + this.cid);
|
||||
},
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ $(document).ready(function() {
|
||||
equals(counter2, 3);
|
||||
});
|
||||
|
||||
test("View: clearEvents", function() {
|
||||
test("View: undelegateEvents", function() {
|
||||
var counter = counter2 = 0;
|
||||
view.el = document.body;
|
||||
view.increment = function(){ counter++; };
|
||||
@@ -67,7 +67,7 @@ $(document).ready(function() {
|
||||
$('#qunit-userAgent').trigger('click');
|
||||
equals(counter, 1);
|
||||
equals(counter2, 1);
|
||||
view.clearEvents();
|
||||
view.undelegateEvents();
|
||||
$('#qunit-userAgent').trigger('click');
|
||||
equals(counter, 1);
|
||||
equals(counter2, 2);
|
||||
|
||||
Reference in New Issue
Block a user