Hey! I have created a class and in the initialize function I created a PeriodicalExecuter which must call a class method every 5 seconds. But how do I reference the class or the class member? I can''t use this can I??? I have this new PeriodicalExecuter(function(pe) { this.processSwap(); }, this.transtime); And I was writing this I thought it wouldn''t work because the this in the function will refer to the function itself right? Can anyone help me out please? Thanks :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I''m attempting to do the same thing. This appears to work: new PeriodicalExecuter (this.processSwap.bind (this), this.transtime); Thomas Woodham Data Editor - The Greenville News 864.298.4302 [BECAUSE THE NEWS NEVER STOPS] ________________________________ From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs@googlegroups.com] On Behalf Of Antonio CS Sent: Friday, November 30, 2007 10:51 AM To: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails-spinoffs] Calling class method from PeriodicalExecuter Hey! I have created a class and in the initialize function I created a PeriodicalExecuter which must call a class method every 5 seconds. But how do I reference the class or the class member? I can''t use this can I??? I have this new PeriodicalExecuter(function(pe) { this.processSwap(); }, this.transtime); And I was writing this I thought it wouldn''t work because the this in the function will refer to the function itself right? Can anyone help me out please? Thanks :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! It worked great! On Nov 30, 2007 4:25 PM, Woodham, Thomas <twoodham-lm4C025e6zTdToeN5bPUx9BPR1lH4CV8@public.gmane.org> wrote:> I''m attempting to do the same thing. This appears to work: > > new PeriodicalExecuter (this.processSwap.bind (this), this.transtime); > > > *Thomas Woodham* > Data Editor - The Greenville News > 864.298.4302 > > [BECAUSE THE NEWS NEVER STOPS] > > > > ------------------------------ > *From:* rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto: > rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] *On Behalf Of *Antonio CS > *Sent:* Friday, November 30, 2007 10:51 AM > *To:* rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > *Subject:* [Rails-spinoffs] Calling class method from PeriodicalExecuter > > Hey! > > I have created a class and in the initialize function I created a > PeriodicalExecuter which must call a class method every 5 seconds. > But how do I reference the class or the class member? I can''t use this can > I??? > I have this > > new PeriodicalExecuter(function(pe) { > this.processSwap(); > }, this.transtime); > > > And I was writing this I thought it wouldn''t work because the this in the > function will refer to the function itself right? > > Can anyone help me out please? > Thanks :) > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I have another problem! I have this inside the class''s method: paths.each( function(img, i) { this.imglist[i] = new Image(); this.imglist[i].src = img; Event.observe( this.imglist[i], ''onload'', function() { alert("Hello"); this.imglist[i].style.display ="none"; this.imglist[thelastone].push(i); //quando a imagem acabar de carregar vai adicionar o seu numero }.bindAsEventListener(this)); //de index a ultima casa do array que contem as imagens todas }.bind(this) ); I think the this is getting binded to the this of the class in the each but not in the function I set in the onload event. I am running this on my local machine so the images load very quickly, but the onload event never fires (I never see a hello box) Can anyone help me out here please? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---