3 test("toggle(Function, Function) - add toggle event and fake a few clicks", function() {
6 fn1 = function(e) { count++; },
7 fn2 = function(e) { count--; },
8 preventDefault = function(e) { e.preventDefault() },
10 if ( $.browser.msie || $.browser.opera || /konquerer/i.test(navigator.userAgent) )
11 ok( false, "click() on link gets executed in IE/Opera/Konquerer, not intended behaviour!" );
13 link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
14 ok( count == 1, "Check for toggle(fn, fn)" );
17 test("unbind(event)", function() {
19 var el = $("#firstp");
21 ok( true, "Fake normal bind" );
23 el.click(function(event) {
25 ok( true, "Fake onebind" );
29 el.click(function() { return; });
31 ok( !el[0].onclick, "Handler is removed" ); // Bug #964
34 test("trigger(event, [data]", function() {
36 var handler = function(event, a, b, c) {
37 ok( a == 1, "check passed data" );
38 ok( b == "2", "check passed data" );
39 ok( c == "abc", "check passed data" );
41 $("#firstp").bind("click", handler).trigger("click", [1, "2", "abc"]);
44 test("bind() with data", function() {
46 var handler = function(event) {
47 ok( event.data, "check passed data exists" );
48 ok( event.data.foo == "bar", "Check value of passed data" );
50 $("#firstp").bind("click", {foo: "bar"}, handler).click();
53 test("bind() with data and trigger() with data", function() {
55 var handler = function(event, data) {
56 ok( event.data, "check passed data exists" );
57 ok( event.data.foo == "bar", "Check value of passed data" );
58 ok( data, "Check trigger data" );
59 ok( data.bar == "foo", "Check value of trigger data" );
61 $("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]);