0

I'm using MultiDatesPicker v1.6.3 for jQuery UI (http://multidatespickr.sourceforge.net/) to display a clickable calendar.

I want to use the addDates method to add pre selected dates to the calendar. like this - http://multidatespickr.sourceforge.net/#pre-select-dates-demo

The documentation states that

The parameter dates can be a string, a date object or an array (of strings or javascript date objects).

I want to add dates from an array I've created like this

var somedates = ['3-3-2015', '4-3-2015', '5-3-2015'];

But I can't work out how to use the array with the option. It works if I use a sting with the option like

addDates: ['3-3-2015', '4-3-2015', '5-3-2015']

But how do I use the array?

Sorry if my terminology is poor!

1 Answer 1

1

You need to make an array that consist of Date type objects, for example:

var date1 = new Date("03/09/2015");
var date1 = new Date("03/11/2015");
var dateArray = [date1, date1];
$('#yourdatepickername').multiDatesPicker({
                        addDates: dateArray});

Remember that you need to use the correct date format(in my case it was MM/dd/yyyy).

You can also use:

 var dateArray= ["09/03/2015", "11/03/2015"]
 $("#yourdatepickername").multiDatesPicker('addDates', dateArray);

The date format in this case must match the format that is set for the datepicker.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! it was the "new Date" bit I was missing and the correct format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.