test("removeAttr(String", function() {\r
ok( $('#mark').removeAttr("class")[0].className == "", "remove class" );\r
});\r
+\r
+test("unbind(event)", function() {\r
+ expect(3);\r
+ var el = $("#firstp");\r
+ el.click(function() {\r
+ ok( true, "Fake normal bind" );\r
+ });\r
+ el.click(function(event) {\r
+ el.unbind(event);\r
+ ok( true, "Fake onebind" );\r
+ });\r
+ el.click().click();\r
+});\r
// Detach an event or set of events from an element
remove: function(element, type, handler) {
if (element.events)
- if (type && element.events[type])
+ if ( type && type.type )
+ delete element.events[ type.type ][ type.handler.guid ];
+ else if (type && element.events[type])
if ( handler )
delete element.events[type][handler.guid];
else
args.unshift( event );
for ( var j in c ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ args[0].handler = c[j];
+
if ( c[j].apply( this, args ) === false ) {
event.preventDefault();
event.stopPropagation();