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

Calendar: Getting the Last-selected Date

Expand Messages
  • Matt Warden
    I seem to recall a discussion when 0.09 was first released about how to obtain the date that was just selected on the calendar (the one which just fired the
    Message 1 of 2 , Jun 1, 2006
    View Source
    • 0 Attachment
      I seem to recall a discussion when 0.09 was first released about how
      to obtain the date that was just selected on the calendar (the one
      which just fired the onselect, for example). I cannot find this
      message, but I thought the answer was to simply call
      getSelectedDates() and pick off the date at index 0.

      We were doing this for a while, but this is no longer working (it may
      never have). I look at the code, and I see you are sorting the dates
      returned by this method (and I'm not sure why):

      /**
      * Gets the list of currently selected dates from the calendar.
      * @return An array of currently selected JavaScript Date objects.
      * @type Date[]
      */
      YAHOO.widget.Calendar_Core.prototype.getSelectedDates = function() {
      var returnDates = new Array();

      for (var d=0;d<this.selectedDates.length;++d)
      {
      var dateArray = this.selectedDates[d];

      var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
      returnDates.push(date);
      }

      returnDates.sort();
      return returnDates;
      };

      So, my question is, what is the proper way to retreive the date which
      fired the current onselect event handler?

      Thanks,


      --
      Matt Warden
      Oxford, OH, USA
      http://mattwarden.com


      This email proudly and graciously contributes to entropy.
    • Steven Peterson
      Matt, This is a slightly complex issue because there are multiple ways that dates can be selected. If you only care about trapping which date was selected when
      Message 2 of 2 , Jun 1, 2006
      View Source
      • 0 Attachment

        Matt,

         

        This is a slightly complex issue because there are multiple ways that dates can be selected. If you only care about trapping which date was selected when clicking the Calendar, you can get at this through the selectCell function. However, if you definitely need to trap the most recently selected date, I would recommend that pass the date reference into onSelect as an arbitrary argument, and access it through the arguments variable in your onSelect implementation. I would caution that you will want to make sure that you pass the relevant arguments in each instance where onSelect is fired (select and selectCell, off the top of my head). The onSelect handler was left fairly ambiguous because of the varying implementations of calendar (single select, multi select, etc). Let me know if that gives you enough info to go on.

         

        Steven Peterson

        Web Developer, Platform Engineering

        Yahoo!

        From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Matt Warden
        Sent: Thursday, June 01, 2006 2:02 PM
        To: ydn-javascript@yahoogroups.com
        Subject: [ydn-javascript] Calendar: Getting the Last-selected Date

         

        I seem to recall a discussion when 0.09 was first released about how
        to obtain the date that was just selected on the calendar (the one
        which just fired the onselect, for example). I cannot find this
        message, but I thought the answer was to simply call
        getSelectedDates() and pick off the date at index 0.

        We were doing this for a while, but this is no longer working (it may
        never have). I look at the code, and I see you are sorting the dates
        returned by this method (and I'm not sure why):

        /**
        * Gets the list of currently selected dates from the calendar.
        * @return      An array of currently selected JavaScript Date objects.
        * @type Date[]
        */
        YAHOO.widget.Calendar_Core.prototype.getSelectedDates = function() {
              var returnDates = new Array();

              for (var d=0;d<this.selectedDates.length;++d)
              {
                    var dateArray = this.selectedDates[d];

                    var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
                    returnDates.push(date);
              }

              returnDates.sort();
              return returnDates;
        };

        So, my question is, what is the proper way to retreive the date which
        fired the current onselect event handler?

        Thanks,


        --
        Matt Warden
        Oxford, OH, USA
        http://mattwarden.com


        This email proudly and graciously contributes to entropy.

        SPONSORED LINKS

        C programming language

        Computer programming languages

        Java programming language

        The c programming language

        C programming language

        Concept of programming language

         


        YAHOO! GROUPS LINKS

         

         


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