0

I'm really just looking to assign additional information to dates. I am currently setting up datepicker with the following:

beforeShowDay: function(date){
    dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
    if ($.inArray(dmy, ajaxDates) != -1) {
         return [true, "","Available"];
    } else {
         return [false,"","unAvailable"];
    }
},

Where ajaxDates is an array containing a list of available dates such as:

var ajaxDates = [ "26-2-2015", "27-2-2015"];

It's for a booking system were I have another array containing the number of seats available for every date. I had seen a post that I can no longer find were someone was attaching additional information to the dates. If someone could point me in the right direction that would be great!

Edit: I have noticed that the a title is attached to each date which on hover shows the tooltip as "Available" or "Unavailable". Is there any easy method to access through the datepicker?

Gouvi
  • 61
  • 4

1 Answers1

0

The solution that I was referring to was: Add custom parameter to jQuery UI Datepicker

An example of how to set additional parameters is as followed:

var input = $("#datepicker");
var result = $("#result");
var courses = {
    "02-09-2013" : "history",
    "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"
});

http://jsfiddle.net/Seandeburca/qbLwD/

Community
  • 1
  • 1
Gouvi
  • 61
  • 4