tags:

views:

82

answers:

2
YAHOO.namespace("yuibook.calendar"); 

//define the lauchCal function which creates the calendar 
YAHOO.yuibook.calendar.launchCal = function() { 

    //create the calendar object, specifying the container 
    var myCal = new YAHOO.widget.Calendar("mycal"); 

    //draw the calendar on screen 
    myCal.render(); 
}

//define the showCal function which shows the calendar
Var showCal = function() { 
    //show the calendar 
    myCal.show(); 
} 

//create calendar on page load
YAHOO.util.Event.onDOMReady(YAHOO.yuibook.calendar.launchCal); 

//attach listener for click event on calendar icon 
YAHOO.util.Event.addListener("calico", "click", showCal); 

//myCal.hide();

The probblem with the code is that i am not able to display the calender when i click the icon. can anybody help. I am knew to this listener

Thanks in Advance

+1  A: 

The problem is that the myCal variable is undefined in the showCal function. The myCal variable is defined in the launchCal function and is only available from within the scope of that function. You'll need to store a reference to your myCal variable.

Something like the following should do the trick:

YAHOO.namespace("yuibook.calendar");

YAHOO.util.Event.onDOMReady(function() {
    YAHOO.yuibook.calendar.myCal = new YAHOO.widget.Calendar("mycal");
    YAHOO.yuibook.calendar.myCal.render();

    YAHOO.util.Event.addListener("calico", "click", YAHOO.yuibook.calendar.myCal.show); 
});

Have a look at this Popup Calendar example from the YUI documentation for more details.

Simon Lieschke
A: 

Hi Simon,

Please tell me how to configure yahoo utils(YUI_2.6.0) in netbeans

That really sounds like the topic of an entirely different question, and it sounds like you're going to need to provide more information about what you are trying to do.
Simon Lieschke