Using multiple rules in YUI3 calendar

293 Views Asked by At

According to this post, using the same name should allow me to create multiple disabledDatesRule inputs. However, in my case it only seems to select the last instance specified. I created the following simplified test case. Ultimately, I would like to switch it to a customrenderer with a colour. If I have to settle for disabling the dates, that works too.

    var today = new Date();
    var dd = today.getDate(); 
    var mm = today.getMonth(); 
    var yyyy = today.getFullYear();        
    var calendar = new Y.Calendar({
      contentBox: "#mycalendar",
      width:'888px',
      showPrevMonth: true,
      showNextMonth: true,
      disabledDatesRule: "tuesdays_and_fridays",

      minimumDate: new Date(yyyy,mm, dd),
      maximumDate: new Date(yyyy,mm, dd+14),

      date: new Date()}).render();

        var rules={};
        var dYear='2014';
        var dMonth='7';
        var dDate='6';
        rules[dYear]={};
        rules[dYear][dMonth]={};
        rules[dYear][dMonth][dDate]="tuesdays_and_fridays";

        var dDate1='7';
        rules[dYear]={};
        rules[dYear][dMonth]={};
        rules[dYear][dMonth][dDate1]="tuesdays_and_fridays";

     calendar.set("customRenderer", {
       rules: rules,
       filterFunction: function (date, node, rules) {
         if (Y.Array.indexOf(rules, 'tuesdays_and_fridays') >= 0) {
           node.addClass("redtext");
         }
       }
     });
1

There are 1 best solutions below

0
Jason Hawkins On BEST ANSWER

Figured it out myself. You can have multiple rules[] declarations, but they must be unique. I removed the second rules[dYear] and rules[dYear][dMonth].