View Single Post
Old 08-10-2009, 04:16 PM   PM User | #2
edric
New to the CF scene

 
Join Date: Aug 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
edric is an unknown quantity at this point
Quote:
Originally Posted by schotte View Post
Hey all,

as I mentioned in the title, I've an issue getting setTimeout to work inside a plugin I am developing.

Code:
$.Plugin = function(obj,opt)
{
     init();
     
     function init() { ... };
     function heartbeat() { ... };

     setTimeout('heartbeat();', 1000);
}
Error: heartbeat is not defined

Anyone dealt with this before?

Cheers
try this

Code:
$.Plugin = function(obj,opt)
{
     init();
     
     function init() { ... };
     function heartbeat() { ... };

     setTimeout(heartbeat, 1000);
}
no braces no parentheses just pass the function object itself instead of a string.
edric is offline   Reply With Quote