I tried it with the following implementation :

function myFunc(a) {
        $A(a).each(function (o) { alert(o) });
}

It doesn't work, because for $A() to be of any use, I have to use $A
(argument), not $A(a), but the fact is, I have several arguments, not
just one. I want to treat the first argument as an Enumerable, and the
other arguments have different purposes.

Here is an actual function:

UI.Observer = function (elements, events, handlers) {
        var elements = (elements && elements.size !== undefined ? elements :
[elements]);
        var events = (events && events.size !== undefined ? events :
[events]);
        var handlers = (handlers && handlers.size !== undefined ? handlers :
[handlers]);
        var handler = null;
        var pairs = $R(1, events.size()).map(function (i) {
                if(typeof handlers[i-1] != "undefined") handler = handlers[i-1];
                if(typeof handler == "function") return { event:events[i-1],
handler:handler };
        });
        var operate = function (method) {
                elements.each(function (element) {
                        pairs.each(function (pair) {
                                if(pair) Event[method](element, pair.event, 
pair.handler);
                        });
                });
        };

        this.go = operate.curry("observe");
        this.stop = operate.curry("stopObserving");

        this.go();
}


--~--~---------~--~----~------------~-------~--~----~
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 prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to