On 2-Aug-06, at 9:23 AM, Eoghan Murray wrote:
> I seem to be writing a lot of code like this:
>
> MochiKit.Base.map(
> function(inputField){
> MochiKit.Signal.connect(
> inputField,
> 'onclick',
> function(e){
> // Do some stuff here
> }
> );
> },
> MochiKit.DOM.getElementsByTagAndClassName("input", null)
> );
>
> Would it be feasible to rewrite Signal.connect to accept a list
> rather than a single dom element so that I could write:
>
> MochiKit.Signal.connect(
> MochiKit.DOM.getElementsByTagAndClassName("input", null),
> 'onclick',
> function(e){
> // Do some stuff here
> }
> );
>
> And Signal would route the onclick event of each of the input
> elements to (in this case) the anonymous function?
> Is this a worthwhile thing to implement?
You might be better off listening on document or window, and in the
'onclick' handler you can call some function or just ignore the
event. When you have many inputFields or when you add/remove them
dynamically, this really works well. Does that make sense? What do
you think?
Thanks,
Beau
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---