On Sun, Mar 15, 2009 at 9:36 AM, Ryan Gahl <[email protected]> wrote:
> What this all means is that these 2 expressions are functionally
>> identical (considering that they are called from within the same
>> execution context):
>>
>> myElement.observe('click', onClick.bind(this));
>> myElement.observe('click', onClick.bindAsEventListener(this));
>>
>
> FWIW, this was not always true in prototype, which is likely where the
> confusion comes from. .bindAsEventListener, once upon a time, _was_ required
> with .observe() - back before elements returned from $() did not get
> .observe() attached to them (when "Event.observe(el, evtName, func);" was
> the only way to use .observe);
>
> I agree, of course, that it is hardly ever needed now, but the fact that
> you identified a case where it _is_ needed (or desirable), kind of points
> towards keeping it in the API. It's not really doing any harm.
>
Actually, now that I think about this more, the real reason it was (and
still is) needed, was that in IE6, that event object had to be pulled from
window.event and then passed into the bound function, otherwise it was
(still is for IE6 support) on the developer to do that part (if (!evt) evt =
window.event;)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---