Forum Moderators: open
YAHOO.util.Event.on( form, 'submit', function(e) {
YAHOO.util.Event.stopEvent(e);
alert("hello");
});
Anything could happen, and when it does I don't want my websites to stop working.
Anyway, that's besides the point, yes I know that YUI is very good and very function and can do anything I want to do. As can script.aculo.us, jQuery, the various dollar functions...
...but what they don't do is TEACH. I want to know how it's done, so I can improve my own code, and expand my own knowledge. I may be able to take techniques from this to other languages I code in, and other projects.
As for stopping the event, it's again browser specific.
Assuming you have a reference to the event (ev), the following will stop the event from propagating up the DOM and prevent the default browser action:
if (ev.stopPropagation) {
ev.stopPropagation();
}
else {
ev.cancelBubble = true;
}
if (ev.preventDefault) {
ev.preventDefault();
}
else {
ev.returnValue = false;
}
AJAX is my worst, but don't tell anyone
Thanks for that little snippet, I'll see if I can get it to work ok now.
P.S. nice reply. Maybe you just got caught up in the moment with that one.