Well, since you're in Prototype, you can do this:
this.doSomething.bind(this).delay(1000, ...);
where the "..." stand for other parameters of doSomething method (if
they are needed).
Eric
On Dec 3, 3:29 pm, Daan Mortier wrote:
> I'm sorry, I made some typos. This is correct:
>
> // where obj is obviously your object
> var func = function() {
> this.doSomething()}.bind( obj );
>
> window.setTimeout( func, 1000 );
>
> Daan
>
> On Thu, Dec 3, 2009 at 15:28, Daan Mortier wrote:
> > To pass a function to setTimeout that is binded to an object of choice, to
> > something along these lines:
>
> > // where obj is obviously your object
> > var func = function() {
> > this.doSomething()
> > }.bind( this );
> > window.setTimeout( func, 1000 );
>
> > Function.prototype.bind is a function that's defined in the Prototype
> > library. Hope this helps.
>
> > Daan
>
> > On Wed, Dec 2, 2009 at 15:25, fma wrote:
>
> >> Hi,
>
> >> I'm new to Prototype. I'm using it to write a little application for
> >> our photoclub. Its goal is to allow users to upload photos, and then
> >> vote for them.
>
> >> I display all the thumbs, and a double-click on a thumb opens the
> >> photo in full-screen (in a div). As the photo can take time to load, I
> >> use setTimeout() to delay the display. The code looks like:
>
> >> But it does not work. In the _show() method, the call to
> >> this._flashNavButtons() leads to an error (this._flashNavButtons() is
> >> not a function). I think I understand why: when called from the
> >> timeout mecanism, 'this' no longer exists, or does not point anymore
> >> on my object...
>
> >> Is there a way to pass 'this' in the timeout callback? I also use such
> >> timeout callback to make the navgation buttons blink 3 times when the
> >> photo is opened in full size…
>
>
--
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.