http://codeasp.net/blogs/raghav_khunger/microsoft-net/1087/jquery-datepicker-enable-specific-dates
dict['dateObjs'] = AvailableDate.objects.all()
<script type="text/javascript">
$(function () {
//'12-22-2012'
var daysToEnable = [
{% for dateObj in dateObjs %}
'{{ dateObj.date|date:"m-d-Y"}}'{% if not forloop.last %},{% endif %}
{% endfor %}
];
$('#datepicker').datepicker({
beforeShowDay: enableSpecificDates,
dateFormat: 'M. dd, yy'
});
function enableSpecificDates(date) {
var month = date.getMonth();
var day = date.getDate();
var year = date.getFullYear();
for (i = 0; i < daysToEnable.length; i++) {
if ($.inArray((month + 1) + '-' + day + '-' + year, daysToEnable) != -1) {
return [true];
}
}
return [false];
}
});
No comments:
Post a Comment