Thanks so much!

Two questions:
1: what are the performance benefits to using the second to the first
version of your code? I’m assuming that binding–then–currying will
have a performance hit over just currying.
2: what’s the best way of debugging javascript in IE? Obviously we
have Firebug for Firefox, but I can’t find anything remotely close
that does the trick.

Thanks,

Edd

On Jun 4, 1:44 pm, kangax <[EMAIL PROTECTED]> wrote:
> I'm not sure how this could work in "other browsers". All methodized
> Element methods in prototype.js are late bound - i.e. context is
> resolved when the method is called. When you #curry document.observe,
> the #observe is not "bound" to document anymore. In the case of -
> $ready - it's instead called within a global context and fails.
>
> // first bind the method to its original receiver
> // then produce a partial with one argument ('dom:loaded') pre-defined
> var $ready = document.observe.bind(document).curry('dom:loaded');
>
> $ready(function(){ ... }); // should work as expected
>
> Another approach is to use "original" Element method - the one that's
> context-free:
>
> var $ready = Element.observe.curry(document, 'dom:loaded');
> $ready(function(){ ... }); // should work as expected
>
> Best,
> kangax
>
> On Jun 4, 6:52 am, redheat <[EMAIL PROTECTED]> wrote:
>
> > I’m stumped. Can anybody tell me why the following code won’t work in
> > IE?
>
> > var $ready = document.observe.curry('dom:loaded');
>
> > This code should – and does in other browsers – allow you to call:
>
> > $ready(function () {
> >     // do things on dom ready
>
> > });
>
> > …instead of…
>
> > document.observe('dom:loaded', function () {
> >     // do things on dom ready
>
> > });
>
> > I use dom:loaded a lot in my code, and so was looking for a quicker
> > way of typing it. Obviously, I could do the Lowpro-style:
>
> > var $ready = function (fn) {
> >     document.observe('dom:loaded', fn);
>
> > }
>
> > but I think .curry is a much more elegant method.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to