Thanks, was just replying with the same solution (found via some more
googling and looking at prototype code).
I have it working now.
Thanks again.
On 12/6/06, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>
> Andrew Kaspick a écrit :
> > Hello,
> >
> > Perhaps I'm missing something here, but if I set an event (say on a
> > link) which returns false.
> >
> > Event.observe(link, 'click', function() { ...; return false;})
> >
> > That false value doesn't seem to be used and my click is triggering
> > the action of following the href for the associated link.
>
> That's simply because the "return false" thing is not quite portable,
> and also because your function's return value is, anyway, not used by
> the event handler.
>
> The CLEAN, PORTABLE way to cancel the default action is to use this in
> your function:
>
> Event.observe(link, 'click', function(e) {
> Event.stop(e);
> // your code here.
> });
>
> Prototype smooths over the differences between W3C's DOM Level 2 Events
> and Microsoft's fully proprietary handling. It ensures your function
> gets passed the event. The Event.stop method does two things, actually:
>
> * It prevents the default action from occurring
> (W3C: event.preventDefault(). IE: event.returnValue = false)
> * It stops event propagation/bubbling
> (W3C: event.stopPropagation(). IE: event.cancelBubble = true)
>
> That's the best way to go that I know of...
>
> --
> Christophe Porteneuve a.k.a. TDD
> "[They] did not know it was impossible, so they did it." --Mark Twain
> Email: [EMAIL PROTECTED]
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---