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

Re: how do I access events in the basic Calendar?

Expand Messages
  • casiewelch
    Okay, here is what I don t understand, probably because I m pretty new to Javascript, although I have been getting the hang of the AJAX stuff no problem, and
    Message 1 of 3 , Mar 3, 2006
    • 0 Attachment
      Okay, here is what I don't understand, probably because I'm pretty
      new to Javascript, although I have been getting the hang of the AJAX
      stuff no problem, and making some functional stuff.

      Anyway, I have some confusion here, and although I know my problems
      may seem mundane, a little clarification would greatly assist me. I
      apologize for being a pain in the ass, but believe me, I am trying
      very hard to figure this stuff out on my own - I'm not just bugging
      you folks for no reason.

      My basic problem is that I don't understand how to listen to the
      Calendar's default events. If I listen to an event like this:

      function init() {
      cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");
      cal1.render();
      YAHOO.util.Event.addListener(cal1.id, "click", fnTest);
      }

      function fnTest () {
      alert("yo!");
      }

      It works no problem - when I click the calendar, the event fires.
      This I understand.

      What I don't understand is how to get to other events, like when the
      I select a cell in the calendar. In the calendar's documentation it
      says:

      onSelect
      void onSelect
      Event executed when a date is selected in the calendar widget.

      When I modify the code above like so:

      YAHOO.util.Event.addListener(cal1.id, "onSelect", fnTest);

      It doesn't work.

      YAHOO.util.Event.addListener(cal1.id, "select", fnTest);

      Doesn't work either.

      So my question is, how do I add listeners for these default events?

      And if someone has the time, my other question is: how do I know
      what the name of the event is? To add a listener to the click
      event, the syntax is:

      YAHOO.util.Event.addListener(cal1.id, "click", fnTest);

      As far as I know, a click event in Javascript is normally
      called "onClick". So why isn't the syntax:

      YAHOO.util.Event.addListener(cal1.id, "onClick", fnTest); ?

      It was only by trial and error that I was able to get this right.
      Is there a resource of some kind where I can see a list of actual
      event names (like onClick, onSelect) and their corresponding Yahoo
      event listener shortform (like click)?

      Again, I humbly apologize for my ignorance and lack of expertise -
      with luck, perserverance and some help from you folks, these
      deficiencies will be temporary.

      Regards,

      -Adrian

      P.S. If any of you have some sample code I could take a look at that
      would clear up this for me, you can send it to adrianduyzer AT
      gmail.com (this yahoo account belongs to my wife).

      --- In ydn-javascript@yahoogroups.com, "casiewelch" <casiewelch@...>
      wrote:
      >
      > Hi there folks -
      >
      > I like the Calendar widget, nice work. Adds a lot of
      > functionality. However, I am banging my head against the wall
      > trying to figure out how to set up events for the basic Calendar.
      >
      > The documentation states that Calendar inherits event-related
      > methods from YAHOO.widget.Calendar_Core such as wireDefaultEvents.
      >
      > The documentation states that wireDefaultEvents "Wires the local
      DOM
      > events for the Calendar, including cell selection, hover, and
      > default navigation that is used for moving back and forth between
      > calendar pages."
      >
      > However, there is no list of events, their names, or (seemingly)
      any
      > documentation on how to listen to or access any of these events.
      >
      > Could someone please enlighten me as to how to use the default
      > events associated with the basic Calendar widget? An example that
      > triggered an alert box when a cell is selected in the Calendar
      would
      > be ideal.
      >
      > Regards,
      >
      > -Adrian
      >
    • Matt Warden
      ... Hash: SHA1 ... It is a method of calendar (you can see this if you look at the API documentation). Hence: cal.onSelect = myfunction; cal.onDeselect =
      Message 2 of 3 , Mar 3, 2006
      • 0 Attachment
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        casiewelch wrote:
        > When I modify the code above like so:
        >
        > YAHOO.util.Event.addListener(cal1.id, "onSelect", fnTest);

        It is a method of calendar (you can see this if you look at the API
        documentation). Hence:

        cal.onSelect = myfunction;
        cal.onDeselect = myotherfunction;

        etc.

        To anticipate the next question, apparently you can get the date
        selected by doing this:

        var datejustadded = (calAvailability.getSelectedDates())[0];

        Although that doesn't seem to be documented anywhere, and I would much
        prefer it being automatically passed to onselect as an argument (similar
        to renderers).

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


        This email proudly and graciously contributes to entropy.
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.1 (GNU/Linux)
        Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

        iD8DBQFECHBVrI3LObhzHRMRAhMXAKC4mbGVeCNEf+s07cW7EFyRONiUjACeMsI8
        z/G7XMVPXdzolw9GOgcem0w=
        =bdVC
        -----END PGP SIGNATURE-----
      Your message has been successfully submitted and would be delivered to recipients shortly.