3 test("bind(), with data", function() {
5 var handler = function(event) {
6 ok( event.data, "bind() with data, check passed data exists" );
7 equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
9 jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
11 ok( !jQuery.data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
14 test("bind(), with data, trigger with data", function() {
16 var handler = function(event, data) {
17 ok( event.data, "check passed data exists" );
18 equals( event.data.foo, "bar", "Check value of passed data" );
19 ok( data, "Check trigger data" );
20 equals( data.bar, "foo", "Check value of trigger data" );
22 jQuery("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).unbind("click", handler);
25 test("bind(), multiple events at once", function() {
29 var handler = function(event) {
30 if (event.type == "click")
32 else if (event.type == "mouseover")
33 mouseoverCounter += 1;
35 jQuery("#firstp").bind("click mouseover", handler).trigger("click").trigger("mouseover");
36 equals( clickCounter, 1, "bind() with multiple events at once" );
37 equals( mouseoverCounter, 1, "bind() with multiple events at once" );
40 test("bind(), multiple events at once and namespaces", function() {
45 var div = jQuery("<div/>").bind("focusin.a", function(e) {
46 equals( e.type, cur, "Verify right single event was fired." );
50 div.trigger("focusin.a");
52 div = jQuery("<div/>").bind("click mouseover", obj, function(e) {
53 equals( e.type, cur, "Verify right multi event was fired." );
54 equals( e.data, obj, "Make sure the data came in correctly." );
61 div.trigger("mouseover");
63 div = jQuery("<div/>").bind("focusin.a focusout.b", function(e) {
64 equals( e.type, cur, "Verify right multi event was fired." );
68 div.trigger("focusin.a");
71 div.trigger("focusout.b");
74 test("bind(), namespace with special add", function() {
77 var div = jQuery("<div/>").bind("test", function(e) {
78 ok( true, "Test event fired." );
83 jQuery.event.special.test = {
84 _default: function(e) {
85 equals( this, document, "Make sure we're at the top of the chain." );
86 equals( e.type, "test", "And that we're still dealing with a test event." );
87 equals( e.target, div[0], "And that the target is correct." );
90 teardown: function(){},
91 add: function( handleObj ) {
92 var handler = handleObj.handler;
93 handleObj.handler = function(e) {
95 handler.apply( this, arguments );
101 div.bind("test.a", {x: 1}, function(e) {
102 ok( !!e.xyz, "Make sure that the data is getting passed through." );
103 equals( e.data.x, 1, "Make sure data is attached properly." );
106 div.bind("test.b", {x: 2}, function(e) {
107 ok( !!e.xyz, "Make sure that the data is getting passed through." );
108 equals( e.data.x, 2, "Make sure data is attached properly." );
115 div.trigger("test.a");
118 div.trigger("test.b");
121 test("bind(), no data", function() {
123 var handler = function(event) {
124 ok ( !event.data, "Check that no data is added to the event object" );
126 jQuery("#firstp").bind("click", handler).trigger("click");
129 test("bind/one/unbind(Object)", function(){
132 var clickCounter = 0, mouseoverCounter = 0;
133 function handler(event) {
134 if (event.type == "click")
136 else if (event.type == "mouseover")
140 function handlerWithData(event) {
141 if (event.type == "click")
142 clickCounter += event.data;
143 else if (event.type == "mouseover")
144 mouseoverCounter += event.data;
148 $elem.trigger("click").trigger("mouseover");
151 var $elem = jQuery("#firstp")
159 click:handlerWithData,
160 mouseover:handlerWithData
165 equals( clickCounter, 3, "bind(Object)" );
166 equals( mouseoverCounter, 3, "bind(Object)" );
169 equals( clickCounter, 4, "bind(Object)" );
170 equals( mouseoverCounter, 4, "bind(Object)" );
172 jQuery("#firstp").unbind({
178 equals( clickCounter, 4, "bind(Object)" );
179 equals( mouseoverCounter, 4, "bind(Object)" );
182 test("bind(), iframes", function() {
183 // events don't work with iframes, see #939 - this test fails in IE because of contentDocument
184 var doc = jQuery("#loadediframe").contents();
186 jQuery("div", doc).bind("click", function() {
187 ok( true, "Binding to element inside iframe" );
188 }).click().unbind('click');
191 test("bind(), trigger change on select", function() {
194 function selectOnChange(event) {
195 equals( event.data, counter++, "Event.data is not a global event object" );
197 jQuery("#form select").each(function(i){
198 jQuery(this).bind('change', i, selectOnChange);
199 }).trigger('change');
202 test("bind(), namespaced events, cloned events", function() {
205 jQuery("#firstp").bind("custom.test",function(e){
206 ok(true, "Custom event triggered");
209 jQuery("#firstp").bind("click",function(e){
210 ok(true, "Normal click triggered");
213 jQuery("#firstp").bind("click.test",function(e){
214 ok(true, "Namespaced click triggered");
217 // Trigger both bound fn (2)
218 jQuery("#firstp").trigger("click");
220 // Trigger one bound fn (1)
221 jQuery("#firstp").trigger("click.test");
223 // Remove only the one fn
224 jQuery("#firstp").unbind("click.test");
226 // Trigger the remaining fn (1)
227 jQuery("#firstp").trigger("click");
229 // Remove the remaining fn
230 jQuery("#firstp").unbind(".test");
232 // Trigger the remaining fn (0)
233 jQuery("#firstp").trigger("custom");
235 // using contents will get comments regular, text, and comment nodes
236 jQuery("#nonnodes").contents().bind("tester", function () {
237 equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" );
238 }).trigger("tester");
240 // Make sure events stick with appendTo'd elements (which are cloned) #2027
241 jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("p");
242 ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
245 test("bind(), multi-namespaced events", function() {
257 function check(name, msg){
258 same(name, order.shift(), msg);
261 jQuery("#firstp").bind("custom.test",function(e){
262 check("custom.test", "Custom event triggered");
265 jQuery("#firstp").bind("custom.test2",function(e){
266 check("custom.test2", "Custom event triggered");
269 jQuery("#firstp").bind("click.test",function(e){
270 check("click.test", "Normal click triggered");
273 jQuery("#firstp").bind("click.test.abc",function(e){
274 check("click.test.abc", "Namespaced click triggered");
277 // Those would not trigger/unbind (#5303)
278 jQuery("#firstp").trigger("click.a.test");
279 jQuery("#firstp").unbind("click.a.test");
281 // Trigger both bound fn (1)
282 jQuery("#firstp").trigger("click.test.abc");
284 // Trigger one bound fn (1)
285 jQuery("#firstp").trigger("click.abc");
287 // Trigger two bound fn (2)
288 jQuery("#firstp").trigger("click.test");
290 // Remove only the one fn
291 jQuery("#firstp").unbind("click.abc");
293 // Trigger the remaining fn (1)
294 jQuery("#firstp").trigger("click");
296 // Remove the remaining fn
297 jQuery("#firstp").unbind(".test");
299 // Trigger the remaining fn (1)
300 jQuery("#firstp").trigger("custom");
303 test("bind(), with same function", function() {
306 var count = 0 , func = function(){
310 jQuery("#liveHandlerOrder").bind("foo.bar", func).bind("foo.zar", func);
311 jQuery("#liveHandlerOrder").trigger("foo.bar");
313 equals(count, 1, "Verify binding function with multiple namespaces." );
315 jQuery("#liveHandlerOrder").unbind("foo.bar", func).unbind("foo.zar", func);
316 jQuery("#liveHandlerOrder").trigger("foo.bar");
318 equals(count, 1, "Verify that removing events still work." );
321 test("bind(), with different this object", function() {
323 var thisObject = { myThis: true },
324 data = { myData: true },
325 handler1 = function( event ) {
326 equals( this, thisObject, "bind() with different this object" );
328 handler2 = function( event ) {
329 equals( this, thisObject, "bind() with different this object and data" );
330 equals( event.data, data, "bind() with different this object and data" );
334 .bind("click", jQuery.proxy(handler1, thisObject)).click().unbind("click", handler1)
335 .bind("click", data, jQuery.proxy(handler2, thisObject)).click().unbind("click", handler2);
337 ok( !jQuery.data(jQuery("#firstp")[0], "events"), "Event handler unbound when using different this object and data." );
340 test("unbind(type)", function() {
343 var $elem = jQuery("#firstp"),
347 ok( false, message );
350 message = "unbind passing function";
351 $elem.bind('error', error).unbind('error',error).triggerHandler('error');
353 message = "unbind all from event";
354 $elem.bind('error', error).unbind('error').triggerHandler('error');
356 message = "unbind all";
357 $elem.bind('error', error).unbind().triggerHandler('error');
359 message = "unbind many with function";
360 $elem.bind('error error2',error)
361 .unbind('error error2', error )
362 .trigger('error').triggerHandler('error2');
364 message = "unbind many"; // #3538
365 $elem.bind('error error2',error)
366 .unbind('error error2')
367 .trigger('error').triggerHandler('error2');
369 message = "unbind without a type or handler";
370 $elem.bind("error error2.test",error)
372 .trigger("error").triggerHandler("error2");
375 test("unbind(eventObject)", function() {
378 var $elem = jQuery("#firstp"),
381 function assert( expected ){
383 $elem.trigger('foo').triggerHandler('bar');
384 equals( num, expected, "Check the right handlers are triggered" );
388 // This handler shouldn't be unbound
389 .bind('foo', function(){
392 .bind('foo', function(e){
397 .bind('bar', function(){
411 test("hover()", function() {
413 handler1 = function( event ) { ++times; },
414 handler2 = function( event ) { ++times; };
417 .hover(handler1, handler2)
418 .mouseenter().mouseleave()
419 .unbind("mouseenter", handler1)
420 .unbind("mouseleave", handler2)
422 .mouseenter().mouseleave()
423 .unbind("mouseenter mouseleave", handler1)
424 .mouseenter().mouseleave();
426 equals( times, 4, "hover handlers fired" );
429 test("trigger() shortcuts", function() {
431 jQuery('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {
432 var close = jQuery('spanx', this); // same with jQuery(this).find('span');
433 equals( close.length, 0, "Context element does not exist, length must be zero" );
434 ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
438 jQuery("#check1").click(function() {
439 ok( true, "click event handler for checkbox gets fired twice, see #815" );
443 jQuery('#firstp')[0].onclick = function(event) {
446 jQuery('#firstp').click();
447 equals( counter, 1, "Check that click, triggers onclick event handler also" );
449 var clickCounter = 0;
450 jQuery('#simon1')[0].onclick = function(event) {
453 jQuery('#simon1').click();
454 equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
456 jQuery('<img />').load(function(){
457 ok( true, "Trigger the load event, using the shortcut .load() (#2819)");
461 test("trigger() bubbling", function() {
464 var doc = 0, html = 0, body = 0, main = 0, ap = 0;
466 jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } });
467 jQuery("html").bind("click", function(e){ html++; });
468 jQuery("body").bind("click", function(e){ body++; });
469 jQuery("#main").bind("click", function(e){ main++; });
470 jQuery("#ap").bind("click", function(){ ap++; return false; });
472 jQuery("html").trigger("click");
473 equals( doc, 1, "HTML bubble" );
474 equals( html, 1, "HTML bubble" );
476 jQuery("body").trigger("click");
477 equals( doc, 2, "Body bubble" );
478 equals( html, 2, "Body bubble" );
479 equals( body, 1, "Body bubble" );
481 jQuery("#main").trigger("click");
482 equals( doc, 3, "Main bubble" );
483 equals( html, 3, "Main bubble" );
484 equals( body, 2, "Main bubble" );
485 equals( main, 1, "Main bubble" );
487 jQuery("#ap").trigger("click");
488 equals( doc, 3, "ap bubble" );
489 equals( html, 3, "ap bubble" );
490 equals( body, 2, "ap bubble" );
491 equals( main, 1, "ap bubble" );
492 equals( ap, 1, "ap bubble" );
495 test("trigger(type, [data], [fn])", function() {
498 var handler = function(event, a, b, c) {
499 equals( event.type, "click", "check passed data" );
500 equals( a, 1, "check passed data" );
501 equals( b, "2", "check passed data" );
502 equals( c, "abc", "check passed data" );
506 var $elem = jQuery("#firstp");
508 // Simulate a "native" click
509 $elem[0].click = function(){
510 ok( true, "Native call was triggered" );
513 // Triggers handlrs and native
515 $elem.bind("click", handler).trigger("click", [1, "2", "abc"]);
517 // Simulate a "native" click
518 $elem[0].click = function(){
519 ok( false, "Native call was triggered" );
522 // Trigger only the handlers (no native)
524 equals( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );
528 jQuery('#form input:first').hide().trigger('focus');
532 ok( pass, "Trigger focus on hidden element" );
536 jQuery('table:first').bind('test:test', function(){}).trigger('test:test');
540 ok( pass, "Trigger on a table with a colon in the even type, see #3533" );
542 var form = jQuery("<form action=''></form>").appendTo("body");
544 // Make sure it can be prevented locally
545 form.submit(function(){
546 ok( true, "Local bind still works." );
551 form.trigger("submit");
553 form.unbind("submit");
555 jQuery(document).submit(function(){
556 ok( true, "Make sure bubble works up to document." );
561 form.trigger("submit");
563 jQuery(document).unbind("submit");
568 test("jQuery.Event.currentTarget", function(){
571 test("trigger(eventObject, [data], [fn])", function() {
574 var $parent = jQuery('<div id="par" />').hide().appendTo('body'),
575 $child = jQuery('<p id="child">foo</p>').appendTo( $parent );
577 var event = jQuery.Event("noNew");
578 ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" );
579 equals( event.type, "noNew", "Verify its type" );
581 equals( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
582 equals( event.isPropagationStopped(), false, "Verify isPropagationStopped" );
583 equals( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
585 event.preventDefault();
586 equals( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" );
587 event.stopPropagation();
588 equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
590 event.isPropagationStopped = function(){ return false };
591 event.stopImmediatePropagation();
592 equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
593 equals( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
595 $parent.bind('foo',function(e){
597 equals( e.type, 'foo', 'Verify event type when passed passing an event object' );
598 equals( e.target.id, 'child', 'Verify event.target when passed passing an event object' );
599 equals( e.currentTarget.id, 'par', 'Verify event.target when passed passing an event object' );
600 equals( e.secret, 'boo!', 'Verify event object\'s custom attribute when passed passing an event object' );
603 // test with an event object
604 event = new jQuery.Event("foo");
605 event.secret = 'boo!';
606 $child.trigger(event);
608 // test with a literal object
609 $child.trigger({type:'foo', secret:'boo!'});
614 ok( false, "This assertion shouldn't be reached");
617 $parent.bind('foo', error );
619 $child.bind('foo',function(e, a, b, c ){
620 equals( arguments.length, 4, "Check arguments length");
621 equals( a, 1, "Check first custom argument");
622 equals( b, 2, "Check second custom argument");
623 equals( c, 3, "Check third custom argument");
625 equals( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
626 equals( e.isPropagationStopped(), false, "Verify isPropagationStopped" );
627 equals( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
630 e.stopImmediatePropagation();
635 // We should add this back in when we want to test the order
636 // in which event handlers are iterated.
637 //$child.bind('foo', error );
639 event = new jQuery.Event("foo");
640 $child.trigger( event, [1,2,3] ).unbind();
641 equals( event.result, "result", "Check event.result attribute");
643 // Will error if it bubbles
644 $child.triggerHandler('foo');
647 $parent.unbind().remove();
650 test("jQuery.Event.currentTarget", function(){
654 $elem = jQuery('<button>a</button>').click(function(e){
655 equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );
659 $elem.trigger('click');
665 test("toggle(Function, Function, ...)", function() {
669 fn1 = function(e) { count++; },
670 fn2 = function(e) { count--; },
671 preventDefault = function(e) { e.preventDefault() },
672 link = jQuery('#mark');
673 link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
674 equals( count, 1, "Check for toggle(fn, fn)" );
676 jQuery("#firstp").toggle(function () {
677 equals(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" )
678 }, function() {}).trigger("click", [ 1, 2, 3 ]);
681 jQuery("#simon1").one("click", function() {
682 ok( true, "Execute event only once" );
683 jQuery(this).toggle(function() {
684 equals( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
686 equals( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
689 }).click().click().click();
704 var $div = jQuery("<div> </div>").toggle( fns[0], fns[1], fns[2] );
706 equals( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1");
708 equals( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2");
710 equals( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3");
712 equals( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1");
714 equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
716 $div.unbind('click',fns[0]);
717 var data = jQuery.data( $div[0], 'events' );
718 ok( !data, "Unbinding one function from toggle unbinds them all");
720 // Test Multi-Toggles
722 $div = jQuery("<div/>");
723 $div.toggle(function(){ a.push(1); }, function(){ a.push(2); });
725 same( a, [1], "Check that a click worked." );
727 $div.toggle(function(){ b.push(1); }, function(){ b.push(2); });
729 same( a, [1,2], "Check that a click worked with a second toggle." );
730 same( b, [1], "Check that a click worked with a second toggle." );
733 same( a, [1,2,1], "Check that a click worked with a second toggle, second click." );
734 same( b, [1,2], "Check that a click worked with a second toggle, second click." );
737 test(".live()/.die()", function() {
740 var submit = 0, div = 0, livea = 0, liveb = 0;
742 jQuery("div").live("submit", function(){ submit++; return false; });
743 jQuery("div").live("click", function(){ div++; });
744 jQuery("div#nothiddendiv").live("click", function(){ livea++; });
745 jQuery("div#nothiddendivchild").live("click", function(){ liveb++; });
747 // Nothing should trigger on the body
748 jQuery("body").trigger("click");
749 equals( submit, 0, "Click on body" );
750 equals( div, 0, "Click on body" );
751 equals( livea, 0, "Click on body" );
752 equals( liveb, 0, "Click on body" );
754 // This should trigger two events
755 jQuery("div#nothiddendiv").trigger("click");
756 equals( submit, 0, "Click on div" );
757 equals( div, 1, "Click on div" );
758 equals( livea, 1, "Click on div" );
759 equals( liveb, 0, "Click on div" );
761 // This should trigger three events (w/ bubbling)
762 jQuery("div#nothiddendivchild").trigger("click");
763 equals( submit, 0, "Click on inner div" );
764 equals( div, 2, "Click on inner div" );
765 equals( livea, 2, "Click on inner div" );
766 equals( liveb, 1, "Click on inner div" );
768 // This should trigger one submit
769 jQuery("div#nothiddendivchild").trigger("submit");
770 equals( submit, 1, "Submit on div" );
771 equals( div, 2, "Submit on div" );
772 equals( livea, 2, "Submit on div" );
773 equals( liveb, 1, "Submit on div" );
775 // Make sure no other events were removed in the process
776 jQuery("div#nothiddendivchild").trigger("click");
777 equals( submit, 1, "die Click on inner div" );
778 equals( div, 3, "die Click on inner div" );
779 equals( livea, 3, "die Click on inner div" );
780 equals( liveb, 2, "die Click on inner div" );
782 // Now make sure that the removal works
783 jQuery("div#nothiddendivchild").die("click");
784 jQuery("div#nothiddendivchild").trigger("click");
785 equals( submit, 1, "die Click on inner div" );
786 equals( div, 4, "die Click on inner div" );
787 equals( livea, 4, "die Click on inner div" );
788 equals( liveb, 2, "die Click on inner div" );
790 // Make sure that the click wasn't removed too early
791 jQuery("div#nothiddendiv").trigger("click");
792 equals( submit, 1, "die Click on inner div" );
793 equals( div, 5, "die Click on inner div" );
794 equals( livea, 5, "die Click on inner div" );
795 equals( liveb, 2, "die Click on inner div" );
797 // Make sure that stopPropgation doesn't stop live events
798 jQuery("div#nothiddendivchild").live("click", function(e){ liveb++; e.stopPropagation(); });
799 jQuery("div#nothiddendivchild").trigger("click");
800 equals( submit, 1, "stopPropagation Click on inner div" );
801 equals( div, 6, "stopPropagation Click on inner div" );
802 equals( livea, 6, "stopPropagation Click on inner div" );
803 equals( liveb, 3, "stopPropagation Click on inner div" );
805 // Make sure click events only fire with primary click
806 var event = jQuery.Event("click");
808 jQuery("div#nothiddendiv").trigger(event);
810 equals( livea, 6, "live secondary click" );
812 jQuery("div#nothiddendivchild").die("click");
813 jQuery("div#nothiddendiv").die("click");
814 jQuery("div").die("click");
815 jQuery("div").die("submit");
817 // Test binding with a different context
818 var clicked = 0, container = jQuery('#main')[0];
819 jQuery("#foo", container).live("click", function(e){ clicked++; });
820 jQuery("div").trigger('click');
821 jQuery("#foo").trigger('click');
822 jQuery("#main").trigger('click');
823 jQuery("body").trigger('click');
824 equals( clicked, 2, "live with a context" );
826 // Make sure the event is actually stored on the context
827 ok( jQuery.data(container, "events").live, "live with a context" );
829 // Test unbinding with a different context
830 jQuery("#foo", container).die("click");
831 jQuery("#foo").trigger('click');
832 equals( clicked, 2, "die with a context");
834 // Test binding with event data
835 jQuery("#foo").live("click", true, function(e){ equals( e.data, true, "live with event data" ); });
836 jQuery("#foo").trigger("click").die("click");
838 // Test binding with trigger data
839 jQuery("#foo").live("click", function(e, data){ equals( data, true, "live with trigger data" ); });
840 jQuery("#foo").trigger("click", true).die("click");
842 // Test binding with different this object
843 jQuery("#foo").live("click", jQuery.proxy(function(e){ equals( this.foo, "bar", "live with event scope" ); }, { foo: "bar" }));
844 jQuery("#foo").trigger("click").die("click");
846 // Test binding with different this object, event data, and trigger data
847 jQuery("#foo").live("click", true, jQuery.proxy(function(e, data){
848 equals( e.data, true, "live with with different this object, event data, and trigger data" );
849 equals( this.foo, "bar", "live with with different this object, event data, and trigger data" );
850 equals( data, true, "live with with different this object, event data, and trigger data")
852 jQuery("#foo").trigger("click", true).die("click");
854 // Verify that return false prevents default action
855 jQuery("#anchor2").live("click", function(){ return false; });
856 var hash = window.location.hash;
857 jQuery("#anchor2").trigger("click");
858 equals( window.location.hash, hash, "return false worked" );
859 jQuery("#anchor2").die("click");
861 // Verify that .preventDefault() prevents default action
862 jQuery("#anchor2").live("click", function(e){ e.preventDefault(); });
863 var hash = window.location.hash;
864 jQuery("#anchor2").trigger("click");
865 equals( window.location.hash, hash, "e.preventDefault() worked" );
866 jQuery("#anchor2").die("click");
868 // Test binding the same handler to multiple points
870 function callback(){ called++; return false; }
872 jQuery("#nothiddendiv").live("click", callback);
873 jQuery("#anchor2").live("click", callback);
875 jQuery("#nothiddendiv").trigger("click");
876 equals( called, 1, "Verify that only one click occurred." );
878 jQuery("#anchor2").trigger("click");
879 equals( called, 2, "Verify that only one click occurred." );
881 // Make sure that only one callback is removed
882 jQuery("#anchor2").die("click", callback);
884 jQuery("#nothiddendiv").trigger("click");
885 equals( called, 3, "Verify that only one click occurred." );
887 jQuery("#anchor2").trigger("click");
888 equals( called, 3, "Verify that no click occurred." );
890 // Make sure that it still works if the selector is the same,
891 // but the event type is different
892 jQuery("#nothiddendiv").live("foo", callback);
895 jQuery("#nothiddendiv").die("click", callback);
897 jQuery("#nothiddendiv").trigger("click");
898 equals( called, 3, "Verify that no click occurred." );
900 jQuery("#nothiddendiv").trigger("foo");
901 equals( called, 4, "Verify that one foo occurred." );
904 jQuery("#nothiddendiv").die("foo", callback);
906 // Make sure we don't loose the target by DOM modifications
907 // after the bubble already reached the liveHandler
908 var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
910 jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); });
911 jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} });
913 jQuery("#nothiddendiv span").click();
914 equals( jQuery("#nothiddendiv span").length, 0, "Verify that first handler occurred and modified the DOM." );
915 equals( livec, 1, "Verify that second handler occurred even with nuked target." );
918 jQuery("#nothiddendivchild").die("click");
920 // Verify that .live() ocurs and cancel buble in the same order as
921 // we would expect .bind() and .click() without delegation
922 var lived = 0, livee = 0;
924 // bind one pair in one order
925 jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; });
926 jQuery('span#liveSpan1').live('click', function(){ livee++; });
928 jQuery('span#liveSpan1 a').click();
929 equals( lived, 1, "Verify that only one first handler occurred." );
930 equals( livee, 0, "Verify that second handler doesn't." );
932 // and one pair in inverse
933 jQuery('span#liveSpan2').live('click', function(){ livee++; });
934 jQuery('span#liveSpan2 a').live('click', function(){ lived++; return false; });
938 jQuery('span#liveSpan2 a').click();
939 equals( lived, 1, "Verify that only one first handler occurred." );
940 equals( livee, 0, "Verify that second handler doesn't." );
943 jQuery("span#liveSpan1 a").die("click")
944 jQuery("span#liveSpan1").die("click");
945 jQuery("span#liveSpan2 a").die("click");
946 jQuery("span#liveSpan2").die("click");
948 // Test this, target and currentTarget are correct
949 jQuery('span#liveSpan1').live('click', function(e){
950 equals( this.id, 'liveSpan1', 'Check the this within a live handler' );
951 equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a live handler' );
952 equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a live handler' );
955 jQuery('span#liveSpan1 a').click();
957 jQuery('span#liveSpan1').die('click');
959 // Work with deep selectors
962 function clickB(){ livee++; }
964 jQuery("#nothiddendiv div").live("click", function(){ livee++; });
965 jQuery("#nothiddendiv div").live("click", clickB);
966 jQuery("#nothiddendiv div").live("mouseover", function(){ livee++; });
968 equals( livee, 0, "No clicks, deep selector." );
971 jQuery("#nothiddendivchild").trigger("click");
972 equals( livee, 2, "Click, deep selector." );
975 jQuery("#nothiddendivchild").trigger("mouseover");
976 equals( livee, 1, "Mouseover, deep selector." );
978 jQuery("#nothiddendiv div").die("mouseover");
981 jQuery("#nothiddendivchild").trigger("click");
982 equals( livee, 2, "Click, deep selector." );
985 jQuery("#nothiddendivchild").trigger("mouseover");
986 equals( livee, 0, "Mouseover, deep selector." );
988 jQuery("#nothiddendiv div").die("click", clickB);
991 jQuery("#nothiddendivchild").trigger("click");
992 equals( livee, 1, "Click, deep selector." );
994 jQuery("#nothiddendiv div").die("click");
997 test("die all bound events", function(){
1001 var div = jQuery("div#nothiddendivchild");
1003 div.live("click submit", function(){ count++; });
1006 div.trigger("click");
1007 div.trigger("submit");
1009 equals( count, 0, "Make sure no events were triggered." );
1012 test("live with multiple events", function(){
1016 var div = jQuery("div#nothiddendivchild");
1018 div.live("click submit", function(){ count++; });
1020 div.trigger("click");
1021 div.trigger("submit");
1023 equals( count, 2, "Make sure both the click and submit were triggered." );
1026 test("live with change", function(){
1027 var selectChange = 0, checkboxChange = 0;
1029 var select = jQuery("select[name='S1']")
1030 select.live("change", function() {
1034 var checkbox = jQuery("#check2"),
1035 checkboxFunction = function(){
1038 checkbox.live("change", checkboxFunction);
1040 // test click on select
1042 // second click that changed it
1044 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1045 select.trigger("change");
1046 equals( selectChange, 1, "Change on click." );
1048 // test keys on select
1050 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1051 select.trigger("change");
1052 equals( selectChange, 1, "Change on keyup." );
1054 // test click on checkbox
1055 checkbox.trigger("change");
1056 equals( checkboxChange, 1, "Change on checkbox." );
1058 // test before activate on radio
1060 // test blur/focus on textarea
1061 var textarea = jQuery("#area1"), textareaChange = 0, oldVal = textarea.val();
1062 textarea.live("change", function() {
1066 textarea.val(oldVal + "foo");
1067 textarea.trigger("change");
1068 equals( textareaChange, 1, "Change on textarea." );
1070 textarea.val(oldVal);
1071 textarea.die("change");
1073 // test blur/focus on text
1074 var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();
1075 text.live("change", function() {
1079 text.val(oldVal+"foo");
1080 text.trigger("change");
1081 equals( textChange, 1, "Change on text input." );
1083 text.val(oldTextVal);
1086 // test blur/focus on password
1087 var password = jQuery("#name"), passwordChange = 0, oldPasswordVal = password.val();
1088 password.live("change", function() {
1092 password.val(oldPasswordVal + "foo");
1093 password.trigger("change");
1094 equals( passwordChange, 1, "Change on password input." );
1096 password.val(oldPasswordVal);
1097 password.die("change");
1099 // make sure die works
1103 select.die("change");
1104 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1105 select.trigger("change");
1106 equals( selectChange, 0, "Die on click works." );
1109 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1110 select.trigger("change");
1111 equals( selectChange, 0, "Die on keyup works." );
1113 // die specific checkbox
1114 checkbox.die("change", checkboxFunction);
1115 checkbox.trigger("change");
1116 equals( checkboxChange, 1, "Die on checkbox." );
1119 test("live with submit", function() {
1120 var count1 = 0, count2 = 0;
1122 jQuery("#testForm").live("submit", function(ev) {
1124 ev.preventDefault();
1127 jQuery("body").live("submit", function(ev) {
1129 ev.preventDefault();
1132 if ( jQuery.support.submitBubbles ) {
1133 jQuery("#testForm input[name=sub1]")[0].click();
1137 jQuery("#testForm input[name=sub1]")[0].click();
1138 jQuery("#testForm input[name=T1]").trigger({type: "keypress", keyCode: 13});
1143 jQuery("#testForm").die("submit");
1144 jQuery("body").die("submit");
1147 test(".delegate()/.undelegate()", function() {
1150 var submit = 0, div = 0, livea = 0, liveb = 0;
1152 jQuery("#body").delegate("div", "submit", function(){ submit++; return false; });
1153 jQuery("#body").delegate("div", "click", function(){ div++; });
1154 jQuery("#body").delegate("div#nothiddendiv", "click", function(){ livea++; });
1155 jQuery("#body").delegate("div#nothiddendivchild", "click", function(){ liveb++; });
1157 // Nothing should trigger on the body
1158 jQuery("body").trigger("click");
1159 equals( submit, 0, "Click on body" );
1160 equals( div, 0, "Click on body" );
1161 equals( livea, 0, "Click on body" );
1162 equals( liveb, 0, "Click on body" );
1164 // This should trigger two events
1165 jQuery("div#nothiddendiv").trigger("click");
1166 equals( submit, 0, "Click on div" );
1167 equals( div, 1, "Click on div" );
1168 equals( livea, 1, "Click on div" );
1169 equals( liveb, 0, "Click on div" );
1171 // This should trigger three events (w/ bubbling)
1172 jQuery("div#nothiddendivchild").trigger("click");
1173 equals( submit, 0, "Click on inner div" );
1174 equals( div, 2, "Click on inner div" );
1175 equals( livea, 2, "Click on inner div" );
1176 equals( liveb, 1, "Click on inner div" );
1178 // This should trigger one submit
1179 jQuery("div#nothiddendivchild").trigger("submit");
1180 equals( submit, 1, "Submit on div" );
1181 equals( div, 2, "Submit on div" );
1182 equals( livea, 2, "Submit on div" );
1183 equals( liveb, 1, "Submit on div" );
1185 // Make sure no other events were removed in the process
1186 jQuery("div#nothiddendivchild").trigger("click");
1187 equals( submit, 1, "undelegate Click on inner div" );
1188 equals( div, 3, "undelegate Click on inner div" );
1189 equals( livea, 3, "undelegate Click on inner div" );
1190 equals( liveb, 2, "undelegate Click on inner div" );
1192 // Now make sure that the removal works
1193 jQuery("#body").undelegate("div#nothiddendivchild", "click");
1194 jQuery("div#nothiddendivchild").trigger("click");
1195 equals( submit, 1, "undelegate Click on inner div" );
1196 equals( div, 4, "undelegate Click on inner div" );
1197 equals( livea, 4, "undelegate Click on inner div" );
1198 equals( liveb, 2, "undelegate Click on inner div" );
1200 // Make sure that the click wasn't removed too early
1201 jQuery("div#nothiddendiv").trigger("click");
1202 equals( submit, 1, "undelegate Click on inner div" );
1203 equals( div, 5, "undelegate Click on inner div" );
1204 equals( livea, 5, "undelegate Click on inner div" );
1205 equals( liveb, 2, "undelegate Click on inner div" );
1207 // Make sure that stopPropgation doesn't stop live events
1208 jQuery("#body").delegate("div#nothiddendivchild", "click", function(e){ liveb++; e.stopPropagation(); });
1209 jQuery("div#nothiddendivchild").trigger("click");
1210 equals( submit, 1, "stopPropagation Click on inner div" );
1211 equals( div, 6, "stopPropagation Click on inner div" );
1212 equals( livea, 6, "stopPropagation Click on inner div" );
1213 equals( liveb, 3, "stopPropagation Click on inner div" );
1215 // Make sure click events only fire with primary click
1216 var event = jQuery.Event("click");
1218 jQuery("div#nothiddendiv").trigger(event);
1220 equals( livea, 6, "delegate secondary click" );
1222 jQuery("#body").undelegate("div#nothiddendivchild", "click");
1223 jQuery("#body").undelegate("div#nothiddendiv", "click");
1224 jQuery("#body").undelegate("div", "click");
1225 jQuery("#body").undelegate("div", "submit");
1227 // Test binding with a different context
1228 var clicked = 0, container = jQuery('#main')[0];
1229 jQuery("#main").delegate("#foo", "click", function(e){ clicked++; });
1230 jQuery("div").trigger('click');
1231 jQuery("#foo").trigger('click');
1232 jQuery("#main").trigger('click');
1233 jQuery("body").trigger('click');
1234 equals( clicked, 2, "delegate with a context" );
1236 // Make sure the event is actually stored on the context
1237 ok( jQuery.data(container, "events").live, "delegate with a context" );
1239 // Test unbinding with a different context
1240 jQuery("#main").undelegate("#foo", "click");
1241 jQuery("#foo").trigger('click');
1242 equals( clicked, 2, "undelegate with a context");
1244 // Test binding with event data
1245 jQuery("#body").delegate("#foo", "click", true, function(e){ equals( e.data, true, "delegate with event data" ); });
1246 jQuery("#foo").trigger("click");
1247 jQuery("#body").undelegate("#foo", "click");
1249 // Test binding with trigger data
1250 jQuery("#body").delegate("#foo", "click", function(e, data){ equals( data, true, "delegate with trigger data" ); });
1251 jQuery("#foo").trigger("click", true);
1252 jQuery("#body").undelegate("#foo", "click");
1254 // Test binding with different this object
1255 jQuery("#body").delegate("#foo", "click", jQuery.proxy(function(e){ equals( this.foo, "bar", "delegate with event scope" ); }, { foo: "bar" }));
1256 jQuery("#foo").trigger("click");
1257 jQuery("#body").undelegate("#foo", "click");
1259 // Test binding with different this object, event data, and trigger data
1260 jQuery("#body").delegate("#foo", "click", true, jQuery.proxy(function(e, data){
1261 equals( e.data, true, "delegate with with different this object, event data, and trigger data" );
1262 equals( this.foo, "bar", "delegate with with different this object, event data, and trigger data" );
1263 equals( data, true, "delegate with with different this object, event data, and trigger data")
1264 }, { foo: "bar" }));
1265 jQuery("#foo").trigger("click", true);
1266 jQuery("#body").undelegate("#foo", "click");
1268 // Verify that return false prevents default action
1269 jQuery("#body").delegate("#anchor2", "click", function(){ return false; });
1270 var hash = window.location.hash;
1271 jQuery("#anchor2").trigger("click");
1272 equals( window.location.hash, hash, "return false worked" );
1273 jQuery("#body").undelegate("#anchor2", "click");
1275 // Verify that .preventDefault() prevents default action
1276 jQuery("#body").delegate("#anchor2", "click", function(e){ e.preventDefault(); });
1277 var hash = window.location.hash;
1278 jQuery("#anchor2").trigger("click");
1279 equals( window.location.hash, hash, "e.preventDefault() worked" );
1280 jQuery("#body").undelegate("#anchor2", "click");
1282 // Test binding the same handler to multiple points
1284 function callback(){ called++; return false; }
1286 jQuery("#body").delegate("#nothiddendiv", "click", callback);
1287 jQuery("#body").delegate("#anchor2", "click", callback);
1289 jQuery("#nothiddendiv").trigger("click");
1290 equals( called, 1, "Verify that only one click occurred." );
1292 jQuery("#anchor2").trigger("click");
1293 equals( called, 2, "Verify that only one click occurred." );
1295 // Make sure that only one callback is removed
1296 jQuery("#body").undelegate("#anchor2", "click", callback);
1298 jQuery("#nothiddendiv").trigger("click");
1299 equals( called, 3, "Verify that only one click occurred." );
1301 jQuery("#anchor2").trigger("click");
1302 equals( called, 3, "Verify that no click occurred." );
1304 // Make sure that it still works if the selector is the same,
1305 // but the event type is different
1306 jQuery("#body").delegate("#nothiddendiv", "foo", callback);
1309 jQuery("#body").undelegate("#nothiddendiv", "click", callback);
1311 jQuery("#nothiddendiv").trigger("click");
1312 equals( called, 3, "Verify that no click occurred." );
1314 jQuery("#nothiddendiv").trigger("foo");
1315 equals( called, 4, "Verify that one foo occurred." );
1318 jQuery("#body").undelegate("#nothiddendiv", "foo", callback);
1320 // Make sure we don't loose the target by DOM modifications
1321 // after the bubble already reached the liveHandler
1322 var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('<span></span>').get(0);
1324 jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(''); });
1325 jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ if(e.target) {livec++;} });
1327 jQuery("#nothiddendiv span").click();
1328 equals( jQuery("#nothiddendiv span").length, 0, "Verify that first handler occurred and modified the DOM." );
1329 equals( livec, 1, "Verify that second handler occurred even with nuked target." );
1332 jQuery("#body").undelegate("#nothiddendivchild", "click");
1334 // Verify that .live() ocurs and cancel buble in the same order as
1335 // we would expect .bind() and .click() without delegation
1336 var lived = 0, livee = 0;
1338 // bind one pair in one order
1339 jQuery("#body").delegate('span#liveSpan1 a', 'click', function(){ lived++; return false; });
1340 jQuery("#body").delegate('span#liveSpan1', 'click', function(){ livee++; });
1342 jQuery('span#liveSpan1 a').click();
1343 equals( lived, 1, "Verify that only one first handler occurred." );
1344 equals( livee, 0, "Verify that second handler doesn't." );
1346 // and one pair in inverse
1347 jQuery("#body").delegate('span#liveSpan2', 'click', function(){ livee++; });
1348 jQuery("#body").delegate('span#liveSpan2 a', 'click', function(){ lived++; return false; });
1352 jQuery('span#liveSpan2 a').click();
1353 equals( lived, 1, "Verify that only one first handler occurred." );
1354 equals( livee, 0, "Verify that second handler doesn't." );
1357 jQuery("#body").undelegate("click");
1359 // Test this, target and currentTarget are correct
1360 jQuery("#body").delegate('span#liveSpan1', 'click', function(e){
1361 equals( this.id, 'liveSpan1', 'Check the this within a delegate handler' );
1362 equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a delegate handler' );
1363 equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a delegate handler' );
1366 jQuery('span#liveSpan1 a').click();
1368 jQuery("#body").undelegate('span#liveSpan1', 'click');
1370 // Work with deep selectors
1373 function clickB(){ livee++; }
1375 jQuery("#body").delegate("#nothiddendiv div", "click", function(){ livee++; });
1376 jQuery("#body").delegate("#nothiddendiv div", "click", clickB);
1377 jQuery("#body").delegate("#nothiddendiv div", "mouseover", function(){ livee++; });
1379 equals( livee, 0, "No clicks, deep selector." );
1382 jQuery("#nothiddendivchild").trigger("click");
1383 equals( livee, 2, "Click, deep selector." );
1386 jQuery("#nothiddendivchild").trigger("mouseover");
1387 equals( livee, 1, "Mouseover, deep selector." );
1389 jQuery("#body").undelegate("#nothiddendiv div", "mouseover");
1392 jQuery("#nothiddendivchild").trigger("click");
1393 equals( livee, 2, "Click, deep selector." );
1396 jQuery("#nothiddendivchild").trigger("mouseover");
1397 equals( livee, 0, "Mouseover, deep selector." );
1399 jQuery("#body").undelegate("#nothiddendiv div", "click", clickB);
1402 jQuery("#nothiddendivchild").trigger("click");
1403 equals( livee, 1, "Click, deep selector." );
1405 jQuery("#body").undelegate("#nothiddendiv div", "click");
1408 test("undelegate all bound events", function(){
1412 var div = jQuery("#body");
1414 div.delegate("div#nothiddendivchild", "click submit", function(){ count++; });
1417 jQuery("div#nothiddendivchild").trigger("click");
1418 jQuery("div#nothiddendivchild").trigger("submit");
1420 equals( count, 0, "Make sure no events were triggered." );
1423 test("delegate with multiple events", function(){
1427 var div = jQuery("#body");
1429 div.delegate("div#nothiddendivchild", "click submit", function(){ count++; });
1431 jQuery("div#nothiddendivchild").trigger("click");
1432 jQuery("div#nothiddendivchild").trigger("submit");
1434 equals( count, 2, "Make sure both the click and submit were triggered." );
1436 jQuery("#body").undelegate();
1439 test("delegate with change", function(){
1440 var selectChange = 0, checkboxChange = 0;
1442 var select = jQuery("select[name='S1']");
1443 jQuery("#body").delegate("select[name='S1']", "change", function() {
1447 var checkbox = jQuery("#check2"),
1448 checkboxFunction = function(){
1451 jQuery("#body").delegate("#check2", "change", checkboxFunction);
1453 // test click on select
1455 // second click that changed it
1457 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1458 select.trigger("change");
1459 equals( selectChange, 1, "Change on click." );
1461 // test keys on select
1463 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1464 select.trigger("change");
1465 equals( selectChange, 1, "Change on keyup." );
1467 // test click on checkbox
1468 checkbox.trigger("change");
1469 equals( checkboxChange, 1, "Change on checkbox." );
1471 // test before activate on radio
1473 // test blur/focus on textarea
1474 var textarea = jQuery("#area1"), textareaChange = 0, oldVal = textarea.val();
1475 jQuery("#body").delegate("#area1", "change", function() {
1479 textarea.val(oldVal + "foo");
1480 textarea.trigger("change");
1481 equals( textareaChange, 1, "Change on textarea." );
1483 textarea.val(oldVal);
1484 jQuery("#body").undelegate("#area1", "change");
1486 // test blur/focus on text
1487 var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();
1488 jQuery("#body").delegate("#name", "change", function() {
1492 text.val(oldVal+"foo");
1493 text.trigger("change");
1494 equals( textChange, 1, "Change on text input." );
1496 text.val(oldTextVal);
1497 jQuery("#body").die("change");
1499 // test blur/focus on password
1500 var password = jQuery("#name"), passwordChange = 0, oldPasswordVal = password.val();
1501 jQuery("#body").delegate("#name", "change", function() {
1505 password.val(oldPasswordVal + "foo");
1506 password.trigger("change");
1507 equals( passwordChange, 1, "Change on password input." );
1509 password.val(oldPasswordVal);
1510 jQuery("#body").undelegate("#name", "change");
1512 // make sure die works
1516 jQuery("#body").undelegate("select[name='S1']", "change");
1517 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1518 select.trigger("change");
1519 equals( selectChange, 0, "Die on click works." );
1522 select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
1523 select.trigger("change");
1524 equals( selectChange, 0, "Die on keyup works." );
1526 // die specific checkbox
1527 jQuery("#body").undelegate("#check2", "change", checkboxFunction);
1528 checkbox.trigger("change");
1529 equals( checkboxChange, 1, "Die on checkbox." );
1532 test("delegate with submit", function() {
1533 var count1 = 0, count2 = 0;
1535 jQuery("#body").delegate("#testForm", "submit", function(ev) {
1537 ev.preventDefault();
1540 jQuery(document).delegate("body", "submit", function(ev) {
1542 ev.preventDefault();
1545 if ( jQuery.support.submitBubbles ) {
1546 jQuery("#testForm input[name=sub1]")[0].click();
1550 jQuery("#testForm input[name=sub1]")[0].click();
1551 jQuery("#testForm input[name=T1]").trigger({type: "keypress", keyCode: 13});
1556 jQuery("#body").undelegate();
1557 jQuery(document).undelegate();
1560 test("Non DOM element events", function() {
1564 .bind('nonelementglobal', function(e) {
1565 ok( true, "Global event on non-DOM annonymos object triggered" );
1571 .bind('nonelementobj', function(e) {
1572 ok( true, "Event on non-DOM object triggered" );
1573 }).bind('nonelementglobal', function() {
1574 ok( true, "Global event on non-DOM object triggered" );
1577 jQuery(o).trigger('nonelementobj');
1578 jQuery.event.trigger('nonelementglobal');
1582 test("jQuery(function($) {})", function() {
1584 jQuery(function($) {
1585 equals(jQuery, $, "ready doesn't provide an event object, instead it provides a reference to the jQuery function, see http://docs.jquery.com/Events/ready#fn");
1590 test("event properties", function() {
1592 jQuery("#simon1").click(function(event) {
1593 ok( event.timeStamp, "assert event.timeStamp is present" );