[Prototype-core] Re: How can I access the object when using each?

2008-02-18 Thread Gareth Evans
who said you could have a week off? i'm not paying you for nothing... get
back to working on prototype... oh wait, never mind
:)



On Feb 19, 2008 2:27 AM, Mislav Marohnić <[EMAIL PROTECTED]> wrote:

> Oh, sorry everyone, I've just seen that Tobie already said this to him.
>
> It can be like this when you're away for a week and then trying to catch
> up :)
>
>
>
> On Feb 18, 2008 2:24 PM, Mislav Marohnić <[EMAIL PROTECTED]>
> wrote:
>
> > kojilab,
> >
> > This group is not for usage questions, but for discussing development of
> > the library. You can ask all your questions on rails-spinoffs group and I'm
> > sure they will be answered shortly. Thanks.
> >
> > - Mislav
> >
> >
> >
> > On Feb 12, 2008 11:52 PM, kojilab <[EMAIL PROTECTED]> wrote:
> >
> > >
> > > Hi Ken and Jon
> > >
> > > Thanks for the info. Since I am not super familiar with the object
> > > model in prototype, what would be the full code to call this
> > > doSomething method within the each() function
> > >
> > > Thanks again
> > >
> > > On Feb 12, 12:28 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> > > > kojilab wrote:
> > > > > Hi
> > > >
> > > > > I have an object with a method I call run that iterates over some
> > > form
> > > > > elements.
> > > > > I want to be able to execute a method of that object on each
> > > element.
> > > > > But when I use this in the function within the each() statement,
> > > > > obviously the this doesn't correspond to the object instance.
> > > > > Thanks for your help
> > > >
> > > > > Code snippet:
> > > > > MyObject=Class.create();
> > > >
> > > > > MyObject.prototype = {
> > > > >   run: function(){
> > > > > this.formElements.each(function(el, index){
> > > > >   this.doSomething(el);
> > > > > });
> > > > >   },
> > > > >  doSomething:function(){
> > > > >   return;
> > > > >  }
> > > > > }
> > > >
> > > > Try $A(this.formElements).each(...);
> > > >
> > > > this.formElements might be a HTML node collection object and not an
> > > array.
> > > >
> > > > - Ken Snyder
> > >
> > >
> >
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: How can I access the object when using each?

2008-02-18 Thread Mislav Marohnić
Oh, sorry everyone, I've just seen that Tobie already said this to him.

It can be like this when you're away for a week and then trying to catch up
:)


On Feb 18, 2008 2:24 PM, Mislav Marohnić <[EMAIL PROTECTED]> wrote:

> kojilab,
>
> This group is not for usage questions, but for discussing development of
> the library. You can ask all your questions on rails-spinoffs group and I'm
> sure they will be answered shortly. Thanks.
>
> - Mislav
>
>
>
> On Feb 12, 2008 11:52 PM, kojilab <[EMAIL PROTECTED]> wrote:
>
> >
> > Hi Ken and Jon
> >
> > Thanks for the info. Since I am not super familiar with the object
> > model in prototype, what would be the full code to call this
> > doSomething method within the each() function
> >
> > Thanks again
> >
> > On Feb 12, 12:28 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> > > kojilab wrote:
> > > > Hi
> > >
> > > > I have an object with a method I call run that iterates over some
> > form
> > > > elements.
> > > > I want to be able to execute a method of that object on each
> > element.
> > > > But when I use this in the function within the each() statement,
> > > > obviously the this doesn't correspond to the object instance.
> > > > Thanks for your help
> > >
> > > > Code snippet:
> > > > MyObject=Class.create();
> > >
> > > > MyObject.prototype = {
> > > >   run: function(){
> > > > this.formElements.each(function(el, index){
> > > >   this.doSomething(el);
> > > > });
> > > >   },
> > > >  doSomething:function(){
> > > >   return;
> > > >  }
> > > > }
> > >
> > > Try $A(this.formElements).each(...);
> > >
> > > this.formElements might be a HTML node collection object and not an
> > array.
> > >
> > > - Ken Snyder
> > > >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: How can I access the object when using each?

2008-02-18 Thread Mislav Marohnić
kojilab,

This group is not for usage questions, but for discussing development of the
library. You can ask all your questions on rails-spinoffs group and I'm sure
they will be answered shortly. Thanks.

- Mislav


On Feb 12, 2008 11:52 PM, kojilab <[EMAIL PROTECTED]> wrote:

>
> Hi Ken and Jon
>
> Thanks for the info. Since I am not super familiar with the object
> model in prototype, what would be the full code to call this
> doSomething method within the each() function
>
> Thanks again
>
> On Feb 12, 12:28 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> > kojilab wrote:
> > > Hi
> >
> > > I have an object with a method I call run that iterates over some form
> > > elements.
> > > I want to be able to execute a method of that object on each element.
> > > But when I use this in the function within the each() statement,
> > > obviously the this doesn't correspond to the object instance.
> > > Thanks for your help
> >
> > > Code snippet:
> > > MyObject=Class.create();
> >
> > > MyObject.prototype = {
> > >   run: function(){
> > > this.formElements.each(function(el, index){
> > >   this.doSomething(el);
> > > });
> > >   },
> > >  doSomething:function(){
> > >   return;
> > >  }
> > > }
> >
> > Try $A(this.formElements).each(...);
> >
> > this.formElements might be a HTML node collection object and not an
> array.
> >
> > - Ken Snyder
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: How can I access the object when using each?

2008-02-12 Thread kojilab

Hi Ken and Jon

Thanks for the info. Since I am not super familiar with the object
model in prototype, what would be the full code to call this
doSomething method within the each() function

Thanks again

On Feb 12, 12:28 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
> kojilab wrote:
> > Hi
>
> > I have an object with a method I call run that iterates over some form
> > elements.
> > I want to be able to execute a method of that object on each element.
> > But when I use this in the function within the each() statement,
> > obviously the this doesn't correspond to the object instance.
> > Thanks for your help
>
> > Code snippet:
> > MyObject=Class.create();
>
> > MyObject.prototype = {
> >   run: function(){
> > this.formElements.each(function(el, index){
> >   this.doSomething(el);
> > });
> >   },
> >  doSomething:function(){
> >   return;
> >  }
> > }
>
> Try $A(this.formElements).each(...);
>
> this.formElements might be a HTML node collection object and not an array.
>
> - Ken Snyder
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: How can I access the object when using each?

2008-02-12 Thread Ken Snyder

kojilab wrote:
> Hi
>
> I have an object with a method I call run that iterates over some form
> elements.
> I want to be able to execute a method of that object on each element.
> But when I use this in the function within the each() statement,
> obviously the this doesn't correspond to the object instance.
> Thanks for your help
>
> Code snippet:
> MyObject=Class.create();
>
> MyObject.prototype = {
>   run: function(){
> this.formElements.each(function(el, index){
>   this.doSomething(el);
> });
>   },
>  doSomething:function(){
>   return;
>  }
> }
>   
Try $A(this.formElements).each(...);

this.formElements might be a HTML node collection object and not an array.

- Ken Snyder

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: How can I access the object when using each?

2008-02-12 Thread Jon L.

For further info: http://prototypejs.org/api/function/bind

- Jon L.

On Feb 12, 2:24 pm, "Jon L." <[EMAIL PROTECTED]> wrote:
> You can use the bind method.
>
>   this.formElements.each(function (el, index) { ... }.bind(this));
>
> - Jon L.
>
> On Feb 12, 2:05 pm, kojilab <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi
>
> > I have an object with a method I call run that iterates over some form
> > elements.
> > I want to be able to execute a method of that object on each element.
> > But when I use this in the function within the each() statement,
> > obviously the this doesn't correspond to the object instance.
> > Thanks for your help
>
> > Code snippet:
> > MyObject=Class.create();
>
> > MyObject.prototype = {
> >   run: function(){
> > this.formElements.each(function(el, index){
> >   this.doSomething(el);
> > });
> >   },
> >  doSomething:function(){
> >   return;
> >  }
>
> > }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: How can I access the object when using each?

2008-02-12 Thread Jon L.

You can use the bind method.

  this.formElements.each(function (el, index) { ... }.bind(this));

- Jon L.

On Feb 12, 2:05 pm, kojilab <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have an object with a method I call run that iterates over some form
> elements.
> I want to be able to execute a method of that object on each element.
> But when I use this in the function within the each() statement,
> obviously the this doesn't correspond to the object instance.
> Thanks for your help
>
> Code snippet:
> MyObject=Class.create();
>
> MyObject.prototype = {
>   run: function(){
> this.formElements.each(function(el, index){
>   this.doSomething(el);
> });
>   },
>  doSomething:function(){
>   return;
>  }
>
> }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---