YUI – Define anonymous function

Defining an anonymous function in order to keep all variables out of the global scope. Inside the anonymous function, define some shortcuts to utils that will be used frequently (Dom and Event).

(function () {
    var Event = YAHOO.util.Event,
    Dom = YAHOO.util.Dom;

Inside the the anonymous function, use the onDOMReady method of the Event utility to instantiate an Overlay and a Button when the page’s DOM is ready to be scripted.

Event.onDOMReady(function () {
    var oCalendarMenu;

    // Create an Overlay instance to house the Calendar instance
    oCalendarMenu = new YAHOO.widget.Overlay("calendarmenu", { visible: false });

    // Create a Button instance of type "menu"

    var oButton = new YAHOO.widget.Button({
       type: "menu",
       id: "calendarpicker",
       label: "Choose A Date",
       menu: oCalendarMenu,
       container: "datefields" });

Leave a Reply

Your email address will not be published. Required fields are marked *