Graeme MacFarlane
Graeme MacFarlane

Reputation: 217

Change the default date of the current inline jQuery UI datepicker

I would like to know if it is possible to change the default date of an already rendered inline datepicker? I have set up a fiddle to play around with: http://jsfiddle.net/xf0qc41k/ I currently destroy the datepicker and re-render it with a new default date if I want the default date to change. This works fine but I wondered if it is possible to change the current inline datepicker's default date on the fly.

HTML:

<div class="inline_datepicker"></div>

JS:

$('.inline_datepicker').datepicker({
    dateFormat: 'yy-mm-dd',
    defaultDate: "2014-10-21",
});

Upvotes: 1

Views: 821

Answers (1)

mccannf
mccannf

Reputation: 16659

Just call setDate:

$('.inline_datepicker').datepicker('setDate', "2014-12-25");

Upvotes: 1

Related Questions