You could also do this with each.

 

$$('div.mydivs').each(myFunction);

 

myFunction will be passed the current element and the index of that element.

 

Brian Marquis | QuoteproR | Senior Developer |  <mailto:b...@quotepro.com>
b...@quotepro.com | Phone: 312.654.8045 x122 / Fax: 312.654.1285

image001

The information in this e-mail is confidential and may be legally
privileged.  It is intended solely for the addressee.   Access to this
e-mail by anyone else is unauthorized.

 

From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptaculous@googlegroups.com] On Behalf Of kstubs
Sent: Saturday, May 05, 2012 11:34 PM
To: prototype-scriptaculous@googlegroups.com
Subject: Re: [Proto-Scripty] Enumerations and Invoke

 

Thanks!  This should work.

On Saturday, May 5, 2012 8:50:58 PM UTC-7, Walter Lee Davis wrote:

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/-/pzlLsFsts8wJ.
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.

-- 
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.

<<image001.png>>

Reply via email to