Search code examples
yuitimedelay

time delay in YUI3


I know things like this are probably best suited to the YUI forums, but I need an answer asap and I may be a while waiting for the YUI forums.

The problem is, I want to transition something in about 14 seconds after the page loads, I know how to run code onload and how to transition elements, but I really can't figure out (or seem to find any information) on how or (even if it is possible) to run the function with a time delay.

Is it possible? If so, how?


Solution

  • appart from just using the javascript setTimeout and assuming YUI 3.

    yui-lang-later has a later method that wraps setTimeout

    var handle = Y.later( 1000 * 14, window, function(){
        // do something 
    }, [], false);
    
    
    // got bored 
    handle.cancel(); // will prevent the function being called.