Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that <code>myCal</code> is a local variable to the <code>launchCal()</code> function. Giving the myCal variable a globally-accessible namespace will make it available to every scope. </p> <p><strong>Here's your original code</strong> (someone else accidentally put my correct code in your original question =/)</p> <pre><code>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(); </code></pre> <p><strong>Now see my changes.</strong> Note the use of the global YAHOO namespace.</p> <pre><code>YAHOO.namespace("yuibook.calendar"); //define the lauchCal function which creates the calendar YAHOO.yuibook.calendar.launchCal = function() { //create the calendar object, specifying the container YAHOO.yuibook.calendar.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 YAHOO.yuibook.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(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload