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

error in Calendar eventSelect

Expand Messages
  • p1nky_pink
    I am trying the use the Calendar and add the selectEvent to it. I have installed Firebug on the Firefox and see the following error selected.concat is not a
    Message 1 of 2 , Oct 9, 2007
    • 0 Attachment
      I am trying the use the Calendar and add the selectEvent to it. I
      have installed Firebug on the Firefox and see the following error

      selected.concat is not a function
      deselectAll()calendar.js (line 2730)
      onBeforeSelect()calendar.js (line 2866)
      fire()event.js (line 217)
      selectCell("3")calendar.js (line 2610)
      doSelectCell(click clientX=0, clientY=0, Calendar cal2
      beforeSelectEvent=Window selectEvent=Window)calendar.js (line 1220)
      CustomEvent(click clientX=0, clientY=0)event-min.js (line 1)
      [Break on this error] var sel = selected.concat();



      I can't paste all the code here, so will try to paste all the code
      relevant, I know its difficult, but please bear with me.

      <!--CSS file (default YUI Sam Skin) -->
      <link rel="stylesheet" type="text/css" href="<html:rewrite
      page='/include/js/yui/build/calendar/assets/calendar.css' />">

      <!-- Dependencies -->
      <script type="text/javascript" src="<html:rewrite
      page='/include/js/yui/build/yahoo-dom-event/yahoo-dom-
      event.js' />"></script>

      <!-- Source file -->
      <script type="text/javascript" src="<html:rewrite
      page='/include/js/yui/build/yahoo/yahoo.js' />"></script>
      <script type="text/javascript" src="<html:rewrite
      page='/include/js/yui/build/event/event.js' />"></script>
      <script type="text/javascript" src="<html:rewrite
      page='/include/js/yui/build/dom/dom.js' />"></script>

      <script type="text/javascript" src="<html:rewrite
      page='/include/js/yui/build/calendar/calendar-min.js' />"></script>
      <script type="text/javascript" src="<html:rewrite
      page='/include/js/yui/build/calendar/calendar.js' />"></script>

      <script>
      var cal1;
      cal1 = new YAHOO.widget.Calendar("cal1","cal1Container",
      { pagedate: startDate, selected: startDate,
      mindate: "1/1/2000", maxdate: "1/1/2020"
      });
      YAHOO.util.Event.addListener(document.getElementById
      ("show1up"), "click", cal1.show, cal1, true);

      var mySelectHandler1 = function(type,args,obj) {
      var s = args[0];
      alert(this._toDate(selected[0]));
      document.getElementById("startDate").innerHTML = this._toDate
      (selected[0]);
      document.getElementById
      ("cal1Container").style.display.value="none";
      };

      cal1.selectEvent.subscribe(mySelectHandler1, cal1, true);
      cal1.render();

      </script>

      <style>
      #cal1Container { display:none; position:absolute; z-index:1}
      </style>


      <table border="0" align="left">
      <tr>
      <td class="bodyText" align="left" class="yui-skin-sam"
      width="50%">From:
      <label id="startDate"></label>
      <a href="#do-nothing" id="show1up"><img
      src="images/common/icn_cal.gif" width="15" height="15" /></a>

      <div style="FONT-SIZE: 60%" id="cal1Container"></div>
      </td>
      </tr>
      </table>


      So, on clicking the image I do see the Calendar, but when I click on
      it to select a date, I get the above error.
      I really don't understand why the selected.concat comes up, as I can
      see the script, when I call the selectEvent, it internally calls the
      deselectAll and thats when this error comes up.

      Can anyone please help me with this?
      Thanks
    • Satyen Desai
      Hi, Using 2.3.1 I don t see the problem, with this cleaned up/filled out version of your code: var cal1; cal1 = new
      Message 2 of 2 , Oct 9, 2007
      • 0 Attachment
        Hi,
        Using 2.3.1 I don't see the problem, with this cleaned up/filled out
        version of your code:

        var cal1;
        cal1 = new YAHOO.widget.Calendar("cal1","cal1Container",
        {
        pagedate: "2/2007",
        selected: "2/17/2007",
        mindate: "1/1/2000",
        maxdate: "1/1/2020"
        });

        YAHOO.util.Event.addListener("show1up",
        "click", cal1.show, cal1, true);

        var mySelectHandler1 = function(type,args,obj) {
        var s = args[0];
        alert(this._toDate(s[0]));
        this.hide();
        };

        cal1.selectEvent.subscribe(mySelectHandler1, cal1, true);
        cal1.render();
        cal1.hide();

        Main areas to look at:

        a). You're including both calendar.js and calendar-min.js. You should
        remove one of them.

        b). You're using the same variable (startDate) for both the pagedate
        and selected options. They both expect a different type of string
        format (http://developer.yahoo.com/yui/calendar/#config). You may also
        want to check what startDate is set to as part of your debugging effort.

        Hope that helps,
        Satyen
      Your message has been successfully submitted and would be delivered to recipients shortly.