Skip to content
Permalink
Browse files

Didn't get specific enough with the proxy guid, fixes #3787.

  • Loading branch information
jeresig committed Jan 9, 2009
1 parent d12e8a3 commit ec7baf230d3c246dadf00c94115e6668425b9354
Showing with 17 additions and 4 deletions.
  1. +2 −2 src/event.js
  2. +15 −2 test/unit/event.js
@@ -545,15 +545,15 @@ jQuery.fn.extend({

live: function( type, fn ){
var proxy = jQuery.event.proxy( fn );
proxy.guid += this.selector;
proxy.guid += this.selector + type;

jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy );

return this;
},

die: function( type, fn ){
jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector } : null );
jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
return this;
}
});
@@ -474,7 +474,7 @@ test("toggle(Function, Function, ...)", function() {
});

test(".live()/.die()", function() {
expect(34);
expect(36);

var submit = 0, div = 0, livea = 0, liveb = 0;

@@ -571,10 +571,23 @@ test(".live()/.die()", function() {
equals( called, 3, "Verify that only one click occurred." );

jQuery("#anchor2").trigger("click");
equals( called, 3, "Verify that only one click occurred." );
equals( called, 3, "Verify that no click occurred." );

// Make sure that it still works if the selector is the same,
// but the event type is different
jQuery("#nothiddendiv").live("foo", callback);

// Cleanup
jQuery("#nothiddendiv").die("click", callback);

jQuery("#nothiddendiv").trigger("click");
equals( called, 3, "Verify that no click occurred." );

jQuery("#nothiddendiv").trigger("foo");
equals( called, 4, "Verify that one foo occurred." );

// Cleanup
jQuery("#nothiddendiv").die("foo", callback);
});

/*

0 comments on commit ec7baf2

Please sign in to comment.
You can’t perform that action at this time.