开发者

Jquery datepicker that consumes json data which are future dates

开发者 https://www.devze.com 2022-12-27 04:09 出处:网络
Is there any jquery datepicker that consumes json data... My json data would be a list of future dates that belongs to any month should be consumed by my开发者_高级运维 datepicker which should be disa

Is there any jquery datepicker that consumes json data... My json data would be a list of future dates that belongs to any month should be consumed by my开发者_高级运维 datepicker which should be disabled and highlighted with a color....


My datepicker provides this functionality using a "renderCallback".

This example shows all weekends styled differently and disabled:

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

And this much more complex example shows setting up different rules based on settings made on the page:

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

Basically you will instantiate the datePicker something like this:

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

Hope it helps :)

0

精彩评论

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