I'm messing around with building an application for the Palm Pre.
I have a simple question: How can I set up a timer for some code to get run after a certain amount of time has passed?
I tried using the regular old javascript setTimeout
, but it doesn't seem to work.
Here is what I've tried:
setTimeout(this.someFunction, 3000);
setTimeout('this.someFunction()', 3000);
Neither one seems to work. How can I accomplish this?
Turns out that the prototype javascript framework is used by Mojo.
I was able to solve this issue by using:
this.someFunction.delay(seconds, [functionArgs,]);
One thing that tripped me up was that the delay
method changed the value of this
, so the delayed function must not expect that this
will be the same as if you had simply invoked it directly.