diff options
author | John Resig <jeresig@gmail.com> | 2009-01-09 22:10:42 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-01-09 22:10:42 +0000 |
commit | d12e8a34e6d96f98ac4f9408a0d61a9ed373f917 (patch) | |
tree | 12a709da13b457e1dedd14fc28f36725c1773904 /test/unit | |
parent | eced38a30d21d025db3e219f3cce7239754316d8 (diff) | |
download | jquery-d12e8a34e6d96f98ac4f9408a0d61a9ed373f917.tar.gz jquery-d12e8a34e6d96f98ac4f9408a0d61a9ed373f917.zip |
Made it so that you can bind a single function to multiple .live() selectors. Additionally, simplified the proxy code to provide a default proxy function.
Fixes #3787.
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/event.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index fb08a2e08..cbeb9ff00 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -474,7 +474,7 @@ test("toggle(Function, Function, ...)", function() { }); test(".live()/.die()", function() { - expect(30); + expect(34); var submit = 0, div = 0, livea = 0, liveb = 0; @@ -550,6 +550,31 @@ test(".live()/.die()", function() { jQuery("#anchor2").trigger("click"); equals( window.location.hash, hash, "e.preventDefault() worked" ); jQuery("#anchor2").die("click"); + + // Test binding the same handler to multiple points + var called = 0; + function callback(){ called++; return false; } + + jQuery("#nothiddendiv").live("click", callback); + jQuery("#anchor2").live("click", callback); + + jQuery("#nothiddendiv").trigger("click"); + equals( called, 1, "Verify that only one click occurred." ); + + jQuery("#anchor2").trigger("click"); + equals( called, 2, "Verify that only one click occurred." ); + + // Make sure that only one callback is removed + jQuery("#anchor2").die("click", callback); + + jQuery("#nothiddendiv").trigger("click"); + equals( called, 3, "Verify that only one click occurred." ); + + jQuery("#anchor2").trigger("click"); + equals( called, 3, "Verify that only one click occurred." ); + + // Cleanup + jQuery("#nothiddendiv").die("click", callback); }); /* |