简体   繁体   中英

Using multiple rules in YUI3 calendar

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");
         }
       }
     });

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].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM