jQuery("#firstp").trigger("custom");
});
+test("bind(), with different this object", function() {
+ expect(4);
+ var thisObject = { myThis: true },
+ data = { myData: true },
+ handler1 = function( event ) {
+ equals( this, thisObject, "bind() with different this object" );
+ },
+ handler2 = function( event ) {
+ equals( this, thisObject, "bind() with different this object and data" );
+ equals( event.data, data, "bind() with different this object and data" );
+ };
+
+ jQuery("#firstp")
+ .bind("click", handler1, thisObject).click().unbind("click", handler1)
+ .bind("click", data, handler2, thisObject).click().unbind("click", handler2);
+
+ ok( !jQuery.data(jQuery("#firstp")[0], "events"), "Event handler unbound when using different this object and data." );
+});
+
test("unbind(type)", function() {
expect( 0 );
});
test("trigger(type, [data], [fn])", function() {
- expect(11);
+ expect(12);
var handler = function(event, a, b, c) {
equals( event.type, "click", "check passed data" );
pass = false;
}
ok( pass, "Trigger focus on hidden element" );
+
+ pass = true;
+ try {
+ jQuery('table:first').bind('test:test', function(){}).trigger('test:test');
+ } catch (e) {
+ pass = false;
+ }
+ ok( pass, "Trigger on a table with a colon in the even type, see #3533" );
});
test("trigger(eventObject, [data], [fn])", function() {
});
test(".live()/.die()", function() {
- expect(54);
+ expect(58);
var submit = 0, div = 0, livea = 0, liveb = 0;
jQuery("#foo").live("click", function(e, data){ equals( data, true, "live with trigger data" ); });
jQuery("#foo").trigger("click", true).die("click");
+ // Test binding with different this object
+ jQuery("#foo").live("click", function(e){ equals( this.foo, "bar", "live with event scope" ); }, { foo: "bar" });
+ jQuery("#foo").trigger("click").die("click");
+
+ // Test binding with different this object, event data, and trigger data
+ jQuery("#foo").live("click", true, function(e, data){
+ equals( e.data, true, "live with with different this object, event data, and trigger data" );
+ equals( this.foo, "bar", "live with with different this object, event data, and trigger data" );
+ equals( data, true, "live with with different this object, event data, and trigger data")
+ }, { foo: "bar" });
+ jQuery("#foo").trigger("click", true).die("click");
+
// Verify that return false prevents default action
jQuery("#anchor2").live("click", function(){ return false; });
var hash = window.location.hash;