Rename to undelegateEvents

As suggested by @jashkenas https://github.com/documentcloud/backbone/pull/620#issuecomment-2132400
This commit is contained in:
Les Hill
2011-09-19 10:30:45 -07:00
parent 1aaffa1302
commit ef40512d84
2 changed files with 4 additions and 4 deletions

View File

@@ -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);
},

View File

@@ -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);