Reputation: 22410
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"?
Upvotes: 6
Views: 6348
Reputation: 407
<script>
YUI().use('event', function (Y) {
var button = Y.one("#readygo");
var buttonname= this.get('value');
alert(buttonname);
}
</script>
<input type="button" name="button" id="readygo" value="Click">
Refer Here: http://yuilibrary.com/yui/docs/
Upvotes: -1
Reputation: 1360
In YUI3 you can do this (see below), but it's not really necessary, if you put the link to the YUI JS at the bottom of the html body tag, as recommended.
YUI().use('node', function(Y) {
Y.on("domready", function(){
console.log('dom is ready');
// your code
});
});
Upvotes: 14
Reputation: 58361
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);
Upvotes: 9