Jquery datepicker,它使用未来日期的json数据

时间:2010-04-19 13:03:13

标签: jquery json datepicker

是否有任何jquery datepicker消耗json数据...我的json数据将是我的datepicker应该使用的任何月份的未来日期列表,应该禁用并用颜色突出显示.... / p>

1 个答案:

答案 0 :(得分:2)

My datepicker使用“renderCallback”提供此功能。

此示例显示所有周末风格不同且已禁用:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerCustomCellRender.html

这个更复杂的例子显示了根据页面上的设置设置不同的规则:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerLimitAvailableDatesAjax2.html

基本上你会将datePicker实例化为:

Date.format = 'yyyy-mm-dd';

// Your data loaded from json - note the date formats match the Date.format you set above
var disabledDates = {'2010-04-21' : true, '2010-05-15' : true};

$('SELECTOR').datePicker(
    {
        renderCallback:function ($td, thisDate, month, year)
        {
            if (disabledDates[thisDate.asString()]) {
                // disabled prevents the date from being selectable, highlight is a hook you can style...
                $td.addClass('disabled highlight');
            }
        }
    }
)

希望有所帮助:)