Message from discussion
Enumerations and Invoke
Date: Sat, 5 May 2012 21:33:37 -0700 (PDT)
From: kstubs <kst...@gmail.com>
To: prototype-scriptaculous@googlegroups.com
Message-ID: <25719836.2942.1336278817574.JavaMail.geo-discussion-forums@ynjb15>
In-Reply-To: <C48C1B6D-991E-4019-AD00-95DF4252B1AB@wdstudio.com>
References: <12070214.101.1336273031011.JavaMail.geo-discussion-forums@ynei13>
<C48C1B6D-991E-4019-AD00-95DF4252B1AB@wdstudio.com>
Subject: Re: [Proto-Scripty] Enumerations and Invoke
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_2940_27114791.1336278817572"
------=_Part_2940_27114791.1336278817572
Content-Type: multipart/alternative;
boundary="----=_Part_2941_15553920.1336278817572"
------=_Part_2941_15553920.1336278817572
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
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..
> >
>
>
------=_Part_2941_15553920.1336278817572
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
Thanks! This should work.<br><br>On Saturday, May 5, 2012 8:50:58 PM UTC-7, Walter Lee Davis wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Take a look at methodize, or you can do this:
<br>
<br>Element.addMethods({
<br> myFunction: function(div){
<br> var div = $(div);
<br> //do whatever here
<br> return div; //for chaining
<br> }
<br>});
<br>
<br>Walter
<br>
<br>On May 5, 2012, at 10:57 PM, kstubs wrote:
<br>
<br>> How do I implement:
<br>>
<br>> I have a function
<br>> I have an enumeration
<br>> On the enumeration I want to invoke my function
<br>> 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.
<br>>
<br>> Suppose I have a collection of <div> elements. I want to invoke my function so my function might look like:
<br>>
<br>> function myFunction(div) {
<br>> // div is the current enumerable object
<br>> }
<br>>
<br>> I call it like this:
<br>> $$('div.mydivs').invoke('<wbr>myFunction')
<br>>
<br>> Thanks,
<br>> Karl..
<br>>
<br><br></blockquote>
------=_Part_2941_15553920.1336278817572--
------=_Part_2940_27114791.1336278817572--