开发者

jQuery UI Datepicker: Highlight 7 days

I am using the jQuery UI Datepicker. It is set to inline so it is displayed to the user all the time.

The datepicker allows you to select one day however I want to be able to select a week (of seven开发者_JAVA技巧 days)

So if the user clicks for example on Wednesday 2009/10/14 it should not only highlight the 2009/10/14 but highlight all days from 2009/10/14 to 2009/10/20.

How can I realize that?


http://jquery-datepicker.googlecode.com/issues/attachment?aid=-4481469706841499120&name=jquery.datePicker.week.js


I know this is an old post but I just ran into the same issue and since the link is broken I'm posting my solution.

    $('#datepicker').datepicker({ 
    dateFormat: 'yy-mm-dd',
    defaultDate: '2011-05-10',
    changeMonth: true,
    changeYear: true,
    beforeShowDay: function(date){
        var selectedDate = new Date('2011-05-10');
        if (date.getFullYear() == selectedDate.getFullYear()
            && date.getMonthName() == selectedDate.getMonthName() 
            && date.getDate() >= selectedDate.getDate() 
            && date.getDate() <= selectedDate.addDays(6).getDate()
            ) {
            return [true, 'ui-datepicker-days-cell highlight', ""];
         }
        return [true, 'ui-datepicker-days-cell',""]
       }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜