jQuery
New Wave Javascript
discuss » First wish for Jquery...
Posted: Sun Jan 29 16:03:57 EST 2006
From: John Resig <
jeresig at gmail.com
>
Hi Mark,
I just realized that I didn't document this at all, here's some more
info on how event binding works in jQuery:
To cancel an event bubble & default action:
$("form").submit(function(){
//... do stuff ...
return false;
});
All you have to do is return false from your function - I check to
see if that happens, and if so, cancel the current event and prevent
the default action.
If you only wish to cancel an event bubble OR the default action, use
these:
$("form").submit(function(e){
e.preventDefault(); // Stop form submission
});
$("form").submit(function(e){
e.stopPropagation(); // Stop event bubbling
});
I hope this clears this up, somewhat. I've updated the documentation
to reflect this:
http://jquery.com/docs/BaseEvents/--John
On Jan 29, 2006, at 3:46 PM, Mark Panay wrote:
>
Hi new list
>
>
I'm loving Jquery, so a big thanks.
>
>
A wish that I currently have is for a way to disable a default action.
>
>
For example I want to put an event on a submit button, I attach a
>
click event to its ID and then perform an AHAH post, but I do not want
>
the form to submit, obviously if JS is not switched on I want the form
>
to submit as "normal".
>
>
Maybe this could come with AJAX update planned? In the meantime
>
anybody know of a "quick fix"?
>
>
mark.
>
>
--
>
Mark Panay
>
www.MarkPanay.com
>
>
_______________________________________________
>
discuss mailing list
>
discuss at jquery.com
>
http://jquery.com/mailman/listinfo/discuss_jquery.com