Take a look at methodize, or you can do this:

Element.addMethods({
        myFunction: function(div){
                var div = $(div);
                //do whatever here
                return div; //for chaining
        }
});

Walter

On May 5, 2012, at 10:57 PM, kstubs wrote:

> How do I implement:
> 
> I have a function
> I have an enumeration
> On the enumeration I want to invoke my function
> My function should either receive the current enumerable object as first 
> parameter - or - within the context of the function "this" should be the 
> current enumerable item.
> 
> Suppose I have a collection of <div> elements.  I want to invoke my function 
> so my function might look like:
> 
> function myFunction(div) {
>   // div is the current enumerable object
> }
> 
> I call it like this:
> $$('div.mydivs').invoke('myFunction')
> 
> Thanks,
> Karl..
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Prototype & script.aculo.us" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/prototype-scriptaculous/-/v1D0luPFTN0J.
> 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/prototype-scriptaculous?hl=en.

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

Reply via email to