On Dec 13, 12:45 am, "Bob Ippolito" <[email protected]> wrote:
> Personally I think it's useful, but I would rather have the connect
> take a selector as a string instead of a list. Makes it much easier to
> track down when the lookup happens in-connect.
>
> connectAll("#my-ul li", "onclick", ...);
>
> (not sold on the name)
>
> We could even have the existing API do this if passed a list, but
> perhaps that's a bit too magical.
>
> connect(["#my-ul li"], "onclick", ...);
>
> The other problem is that the return signature has to change for
> disconnect, or we have to allow for a different kind of disconnect.
>
> -bob

What I like in MochiKit is that you can pass an id to be looked up by
getElement anywhere a DOM node is expected.

Some functions, such as connect, could adapt naturally to receiving a
list instead of a node (others, such as swapDOM, do not).

This might be a crazy suggestion, but if the goal here is to integrate
selectors throughout MochiKit, a nice way to do it might be to use
findDocElements instead of getElement when a string is passed instead
of a node.
Implemented along the lines of the following (thanks Arnar):

    connect(src, sig, objOrFunc, funcOrStr) {
         // removed:        src = MochiKit.DOM.getElement(src);
         if (typeof(src) == 'string') {
             return map(function (el) { return connect(el, sig,
objOrFunc, funcOrStr);}, MochiKit.Selector.findDocElements(src));
        } else {
             // current connect code for a single element
        }
    }

This would be backwards incompatible as current code such as:
   connect('my-id', 'onclick', ....)
Would have to be rewritten as:
   connect('#my-id', 'onclick', ....)

IMO think this would give MochiKit a lot of the ease of use of JQuery,
where selectors are pervasive.

Is this a bridge too far?

Eoghan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" 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/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to