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

50262Re: setting links from calendar

Expand Messages
  • theblargoner
    Jul 5, 2009
    • 0 Attachment
      Hi,
      The Calendar does not provide any simple mechanism by which to attach custom URLs to date cell anchors. The simplest way to accomplish what you want is probably to subscribe to selectEvent, and then based on whichever date is selected (assuming a single-select Calendar for simplicity), use any standard JS method to navigate to the desired URL (for example, setting location.href, calling window.open(), etc.)

      You could set up an array of dates and URLs to make this easier. So your code might look something like:

      (function() {
      var myDateURLs = [
      { date: [2009,1,1], url: 'http://www.yahoo.com/' },
      { date: [2009,7,15], url: 'http://www.yuiblog.com/' }
      ];

      var myCal = new YAHOO.widget.Calendar(...);

      myCal.selectEvent.subscribe(function(type, args) {
      var s = args[0][0], d;
      for(var i = myDateURLs.length - 1; i >= 0; i--) {
      d = myDateURLs[i].date;
      if(s[0] === d[0] && s[1] === d[1] && s[2] === d[2]) {
      location.href = myDateURLs[i].url;
      }
      }
      });

      })();

      Does that help?
      John

      --- In ydn-javascript@yahoogroups.com, "tpluta" <tpluta@...> wrote:
      >
      > Hi John
      >
      > Thank you very much for your reply. I have spent some time exploring the sample you recommended, but the scripts I have found are not too user friendly. I can not figure out on how to pass links for the click event. Using this sample I have created simple page with calendar only, copied two required script files and two css files. All looks as I want, I can easily customise CSS but I have not found where in js files I will be able to setup links to files (i.e. pdf files located on the server). I can find several places where I suspect links may be added but I do not know on how to add several links, one for selected dates. Could you please give me a bit more advice. Thank you.
      >
      > Regards,
      >
      > Tony
      >
    • Show all 4 messages in this topic