2010-04-19 44 views

回答

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

基本上你将实例的日期选择是这样的:

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

希望它有帮助:)

+0

@vitch伟大的人你的代码正是我想要的... – 2010-04-19 16:43:05

相关问题