Hi, > if (this.timeout) this.hide.delay(3);
You're losing context (the meaning of `this`) when you call Function#delay, exactly the same way you lose context when setting up an event handler. Functions are just functions, they do not have `this` burned into them. So when `hide` gets called three seconds later, the `this` value will be wrong. More on the theory behind all of this here[1] and here[2]. There are lots of ways to preserve context; an easy one is Prototype's Function#bind[3]. Off-the-cuff, that would look like this: if (this.timeout) this.hide.bind(this).delay(3); If performance is an issue, though, be aware that *both* #bind and #delay create functions (closures) on the fly, so the above is a tad inefficient, but has the advantage that the closures that are created are created in a fairly well-controlled context within Prototype to minimize what they close over. [1] http://blog.niftysnippets.org/2008/04/you-must-remember-this.html [2] http://blog.niftysnippets.org/2008/03/mythical-methods.html [3] http://api.prototypejs.org/language/function.html#bind-instance_method HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Nov 25, 6:34 pm, Darian Ka <darian...@mail.ru> wrote: > I need call 'delay' within the class: > > var Informer = Class.create({ > ...... > hide: function() { > this.element.hide(); > }, > > show: function() { > this.element.show(); > if (this.timeout) this.hide.delay(3); > } > ...... > > }); > > But it dosent work.Help plz. -- 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-scriptacul...@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.