I would like to use the following method, but use a list instead of a couple of dates.
addDisabledDates: [today.setDate(1), today.setDate(3)]
This is the code for my calender:
$("#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); } });
This is the method to get the dates:
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);
And this is what i get out by inspecting the site now:
["12", "11", "2009"] General.js:101 Thu Nov 12 2009 00:00:00 GMT+0100 (W. Europe Standard Time)
Theres two different types cause im logging both atm.
Any ideas how i can insert my list of dates into the addDisabledDates method?
EDIT: I got it working!
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);
}
});
};