Loading ...
Sorry, an error occurred while loading the content.

[ydn-javascript] Calendar does not disappear when a date is selected

Expand Messages
  • Rebecca Oehmen
    Hi, I just switched replaced some old calendar code with the YUI Calendar code, and I am learning things as I go. The calendar is a fairly standard 1 month
    Message 1 of 3 , Feb 2, 2007
    • 0 Attachment

      Hi,

      I just switched replaced some old calendar code with the YUI Calendar code, and I am learning things as I go. The calendar is a fairly standard 1 month popup calendar that has blocked out days.  The calendar looks great and is working pretty well, but I was wondering if anyone else was having the same problem as me; although I have an event handler (shown below) to hide the pop-up calendar when a date is selected, it occasionally doesn’t work.  If you click an arrow to another month, it usually won’t work, but sometimes it doesn’t work even if a date is selected immediately after it is opened.

       

      YAHOO.wizard.calendar.cal1.selectEvent.subscribe(mySelectHandler, YAHOO.wizard.calendar.cal1, true);

      YAHOO.wizard.calendar.cal1.render();

      YAHOO.util.Event.addListener("showCal_min", "click", YAHOO.wizard.calendar.cal1.show, YAHOO.wizard.calendar.cal1, true); //shows calendar when clicked

      YAHOO.util.Event.addListener("cal1Container_min", "click", YAHOO.wizard.calendar.cal1.hide, YAHOO.wizard.calendar.cal1, true);   //hides calendar when clicked

        

      It wasn’t listed on SourceForge as a bug or requested feature, but perhaps I have my listeners set up incorrectly? Does anyone have ideas?


      Thanks,
      Rebecca

    • Satyen Desai
      Hey Rebecca, I don t see your mySelectHandler in the code snippet you posted, but this is probably the place to hide your calendar. That way you don t need
      Message 2 of 3 , Feb 2, 2007
      • 0 Attachment
        Hey Rebecca,

        I don't see your "mySelectHandler" in the code snippet you posted, but this is probably the place to hide your calendar. That way you don't need to attach a DOM event handler to (what seems to be) the Calendar Container DIV

        Here's an example which hides the calendar on selection after picking up the selected date, which seems to work consistently...

        <!-- Doesn't account for positioning the calendar in relation to the text box, just needed somewhere to dump the selected value -->
        <input type="text" id="date" name="date" /><button id="showCal">Pick Date</button>
        <div id="cal1Container"></div>

        <script type="text/javascript">

        function init() {
                       
            function selectHandler(type, args, cal) {
           
                var selDateArray = args[0][0];

                var yr = selDateArray[0];
                var month = selDateArray[1];
                var dt = selDateArray[2];
                           
                YAHOO.util.Dom.get("date").value = month + "/" + dt + "/" + yr;

                cal.hide();
            }
                       
            var cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");
            cal1.selectEvent.subscribe(selectHandler, cal1);
                       
            cal1.hide();
            cal1.render();
                       
            YAHOO.util.Event.addListener("showCal", "click", cal1.show, cal1, true);
        }
                       
        YAHOO.util.Event.addListener(window, "load", init);
        </script>
      • Rebecca Oehmen
        Hi Satyen, Thanks so much for your help. Adding cal.hide( ) to my selectHandler function fixed the problem and now it works great! ~Rebecca _____ From:
        Message 3 of 3 , Feb 5, 2007
        • 0 Attachment

          Hi Satyen,

          Thanks so much for your help. Adding ‘cal.hide( )’ to my selectHandler function fixed the problem and now it works great!

          ~Rebecca

           


          From: ydn-javascript@yahoogroups.com [mailto: ydn-javascript@yahoogroups.com ] On Behalf Of Satyen Desai
          Sent: Friday, February 02, 2007 7:44 PM
          To: ydn-javascript@yahoogroups.com
          Subject: [ydn-javascript] Re: Calendar does not disappear when a date is selected

           

          Hey Rebecca,

          I don't see your "mySelectHandler" in the code snippet you posted, but this is probably the place to hide your calendar. That way you don't need to attach a DOM event handler to (what seems to be) the Calendar Container DIV

          Here's an example which hides the calendar on selection after picking up the selected date, which seems to work consistently. ..

          <!-- Doesn't account for positioning the calendar in relation to the text box, just needed somewhere to dump the selected value -->
          <input type="text" id="date" name="date" /><button id="showCal">Pick Date</button>
          <div id="cal1Container"></div>

          <script type="text/javascri pt">


          function init() {
                         
              function selectHandler( type, args, cal) {
             
                  var selDateArray = args[0][0];

                  var yr = selDateArray[ 0];
                  var month = selDateArray[ 1];
                  var dt = selDateArray[ 2];
                             
                  YAHOO.util.Dom. get("date" ).value = month + "/" + dt + "/" + yr;

                  cal.hide();

              }
                         
              var cal1 = new YAHOO.widget. Calendar( "cal1","cal1Cont ainer");
              cal1.selectEvent. subscribe( selectHandler, cal1);
                         
              cal1.hide();
              cal1.render( );
                         
              YAHOO.util.Event. addListener( "showCal" , "click", cal1.show, cal1, true);
          }
                         
          YAHOO.util.Event. addListener( window, "load", init);
          </script>

        Your message has been successfully submitted and would be delivered to recipients shortly.