]> source.dussan.org Git - jquery.git/commitdiff
Didn't get specific enough with the proxy guid, fixes #3787.
authorJohn Resig <jeresig@gmail.com>
Fri, 9 Jan 2009 22:14:48 +0000 (22:14 +0000)
committerJohn Resig <jeresig@gmail.com>
Fri, 9 Jan 2009 22:14:48 +0000 (22:14 +0000)
src/event.js
test/unit/event.js

index 405e19f4d0f268075f5164aa067603ff080a858e..1ba0357d2252760091d6310bcade548de394a9d9 100644 (file)
@@ -545,7 +545,7 @@ 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 );
 
@@ -553,7 +553,7 @@ jQuery.fn.extend({
        },
        
        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;
        }
 });
index cbeb9ff0011c9f59650c4b1c653b4a14bb9094db..e12f3b753c9e8be5cec65e5b2abfd861b1a0c51a 100644 (file)
@@ -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);
 });
 
 /*