I am looking for a way to add a parameter to the dates in the jQuery UI Datepicker. I am using the Datepicker to display course start dates. The parameter I need would be t
Heres my attempt using the onSelect method for datepicker.
I have not updated the underlying Date object, instead just added a new data attribute to the "Result" input field. On select, it searches an object called courses (representing your list of course ids and dates) for a match for the selected date.
Inspect the input field with firebug/developer tools to see the data-course-id attribute update. First 3 days of the month have associated courses...
http://jsfiddle.net/Seandeburca/qbLwD/
var input = $("#datepicker");
var result = $("#result");
var courses = {
"01-09-2013" : "javascript",
"02-09-2013" : "history",
"03-09-2013" : "biology",
"10-09-2013": "physics"
};
input.datepicker({
dateFormat: 'dd-mm-yy',
showWeek: true,
firstDay: 1,
numberOfMonths: 3,
onSelect: function(dateText, pickerObj){
result.attr("data-course-id", courses[dateText]);
course.innerHTML = courses[dateText];
},
altField: "#result"
});