Or you could just switch over to using the new prototype 1.6_rc0 that
has been released which takes care of correcting the 'this' scope and
also extends the event object so you can just use e.stop(). So the
following should work (note: not actually tried - just off the top of
my head)
$$('a.popout').invoke('observe', 'click', popout);
function popout(e)
{
window.open(this.href, this.innerHTML,
'width=500,height=500');
e.stop();
}
On Aug 15, 11:36 pm, Christian Schaefer <[EMAIL PROTECTED]> wrote:
> hi wal5hy,
>
> three thought on this:
>
> 1. events you observe do not act like events you assign a single
> callback to. while element.onclick = function(){return false;} has the
> desired effect, it won't have it when using Event.observe() because
> observed events are not finished when the callback is through. this way
> you can have more than one callback observing the same event.
> walter is right Event.stop() will help you.
>
> 2. you have a scope problem. when popup() is called your 'this' will not
> necessarily point to the anchor. it will more likely loose its scope and
> point to window instead. you want to look up bindAsEventListener()[1]
> it will help you.
>
> 3. instead of this
> $$('a.popout').each(function(thePopout){Event.observe(thePopout,'click',popout);});
> you could just use
> $$('a.popout').invoke('observe', 'click', popout);
> which does the same here but imho is more elegant. no error though.
>
> cheers
> /christian
>
> [1]http://prototypejs.org/api/function/bindAsEventListener
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---