我想使用以下方法,但使用列表而不是几个日期。
addDisabledDates: [today.setDate(1), today.setDate(3)]
这是我的日历的代码:
$("#ExceptionDates").multiDatesPicker({
defaultDate: "+1w", firstDay: 1, dateFormat: "dd.mm.yy", numberOfMonths: 1, **addDisabledDates: ['06/19/2012','06/20/2012'],** (NOT working) onSelect: function () { var dates = $("#ExceptionDates").multiDatesPicker('getDates'); var html = ''; $.each(dates, function (i, val) { html += '<input type="text" name="Dates" value="' + val + '">'; }); $("#SelectedDates").html(html); } });
这是获取日期的方法:
var getSelectedExceptionDates = function(callback)
{
$.ajax({
type: "POST",
url: "/Route/GetSelectedExceptionDates/",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response)
{
callback(response);
},
error: function (err)
{
console.log(err);
}
});
};
var callback = function (dates)
{
$.each(dates, function (i, date)
{
var splitDate = date.split('.');
var day = splitDate[0];
var month = splitDate[1];
var year = splitDate[2];
console.log(splitDate);
console.log(new Date(year, (parseInt(month)-1).toString(), day));
});
};
getSelectedExceptionDates(callback);
这就是我现在通过检查网站得到的结果:
["12", "11", "2009"] General.js:101 Thu Nov 12 2009 00:00:00 GMT+0100(西欧标准时间)
有两种不同的类型导致即时记录两个 atm。
有什么想法可以将我的日期列表插入到 addDisabledDates 方法中吗?
编辑:我让它工作了!
var callback = function (dates)
{
var date_ary = new Array();
$.each(dates, function (i, date)
{
var splitDate = date.split('.');
var day = splitDate[0];
var month = splitDate[1];
var year = splitDate[2];
date_ary.push(new Date(month + "/" + day + "/" + year));
});
console.log(date_ary);
$("#ExceptionDates").multiDatesPicker({
minDate: 0,
defaultDate: "+1w",
firstDay: 1,
dateFormat: "dd.mm.yy",
addDisabledDates: date_ary,
numberOfMonths: 1,
onSelect: function ()
{
var dates = $("#ExceptionDates").multiDatesPicker('getDates');
var html = '';
$.each(dates, function (i, val)
{
html += '<input type="text" name="Dates" value="' + val + '">';
});
$("#SelectedDates").html(html);
}
});
};
getSelectedExceptionDates(callback);
var getSelectedExceptionDates = function (callback)
{
$.ajax({
type: "POST",
url: "/Route/GetSelectedExceptionDates/",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response)
{
callback(response);
},
error: function (err)
{
console.log(err);
}
});
};