On 2/9/06, Jeremy Kitchen <[EMAIL PROTECTED]> wrote: > as for this, I believe Event.observe handles finding the proper event object > for you and passes that to your function. This is what I've experienced > anyways :)
Event.observe() does nothing to smooth out passing the event in as a parameter to your handler; that's what bindAsEventListener does. Firefox/Mozilla/? pass the event in as a parameter. Internet Explorer expects you to use window.event to get at it. If you use the event object (say to get at the target), then you either need to smooth out the differences yourself or just use bindAsEventListener. > Since I'm using behaviour.js and sometimes calling behaviour.apply() multiple > times per page-session, I can't use Event.observe, unfortunately :( I > probably can, but just don't know how, yet ;) There's a patch in trac to add behavior-like functionality directly to Prototype. Sam has expressed interest in it. http://dev.rubyonrails.org/ticket/3568 > Flame me if I'm wrong, but couldn't you just skip the 'this' part and use 'el' > directly? > > something like: > Event.observe(el, 'click', (function(event) { > Element.addClassName(el, 'myClass'); > ); Yes, but without seeing more of the code, I can't guarantee that he's not corrupting 'el' elsewhere. He might be re-using it. The bindAsEventListener creates another closure and guarantees that 'this' is what he wants inside of his handler. Todd _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs