Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
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! &nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myFunction: function(div){
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var div = $(div);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//do whatever here
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return div; //for chaining
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>});
<br>
<br>Walter
<br>
<br>On May 5, 2012, at 10:57 PM, kstubs wrote:
<br>
<br>&gt; How do I implement:
<br>&gt; 
<br>&gt; I have a function
<br>&gt; I have an enumeration
<br>&gt; On the enumeration I want to invoke my function
<br>&gt; 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>&gt; 
<br>&gt; Suppose I have a collection of &lt;div&gt; elements. &nbsp;I want to invoke my function so my function might look like:
<br>&gt; 
<br>&gt; function myFunction(div) {
<br>&gt; &nbsp; // div is the current enumerable object
<br>&gt; }
<br>&gt; 
<br>&gt; I call it like this:
<br>&gt; $$('div.mydivs').invoke('<wbr>myFunction')
<br>&gt; 
<br>&gt; Thanks,
<br>&gt; Karl..
<br>&gt; 
<br><br></blockquote>
------=_Part_2941_15553920.1336278817572--

------=_Part_2940_27114791.1336278817572--