});
function liveHandler( event ){
- var check = RegExp("(^|\\.)" + event.type + "(\\.|$)");
+ var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"), stop = true;
jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
if ( check.test(fn.type) ) {
var elem = jQuery(event.target).closest(fn.data)[0];
- if ( elem )
- jQuery.event.trigger( event.type, fn.data, elem, false, fn, false );
+ if ( elem ) {
+ var ret = jQuery.event.trigger( event.type, [event, fn.data], elem, false, fn, false );
+ if ( ret === false )
+ stop = false;
+ }
}
});
+ return stop;
}
function liveConvert(type, selector){
});
test(".live()/.die()", function() {
- expect(28);
+ expect(30);
var submit = 0, div = 0, livea = 0, liveb = 0;
jQuery("div#nothiddendiv").die("click");
jQuery("div").die("click");
jQuery("div").die("submit");
+
+ // Verify that return false prevents default action
+ jQuery("#anchor2").live("click", function(){ return false; });
+ var hash = window.location.hash;
+ jQuery("#anchor2").trigger("click");
+ equals( window.location.hash, hash, "return false worked" );
+ jQuery("#anchor2").die("click");
+
+ // Verify that .preventDefault() prevents default action
+ jQuery("#anchor2").live("click", function(e){ e.preventDefault(); });
+ var hash = window.location.hash;
+ jQuery("#anchor2").trigger("click");
+ equals( window.location.hash, hash, "e.preventDefault() worked" );
+ jQuery("#anchor2").die("click");
});
/*