tags:

views:

350

answers:

1

I experienced with JQuery and new to YUI.

I'm looking for YUI's equivalent of the JQuery "$(document).ready".

I found "onDOMReady". If I have a .JS document with a large number of functions, what is the right way to wrap them all in "onDOMReady"?

+6  A: 
YAHOO.util.Event.onDOMReady(function(){

    YAHOO.myModule.init();
    YAHOO.myOtherModule.init();

    });

I usually do something like the above. Otherwise you can do things like the following if you just need a specific element to be present

YAHOO.util.Event.onAvailable('required-element', YAHOO.myModule.init);
David Caunt
With JQuery, you can add any chunk of code within document.ready. It seems with YUI that you have to use YUI modules. How can I easily wrap a block of functions into a module in order to use onDOMREADY?
You can use any code within onDOMReady, just like in jquery. It's just a callback that gets executed at the specified time.
Tivac