Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI Datepicker - setDate not working

I know this question has been asked on SO before, but I can't figure out what I'm missing. Here is a simple Fiddle.

The jquery:

var myDate = new Date(1978,2,11) 
$('#datepicker').datepicker('setDate', myDate);
like image 728
Ryan Grush Avatar asked Aug 15 '12 00:08

Ryan Grush


1 Answers

You have to initialize the datepicker first:

    $('#datepicker').datepicker();

When you pass setDate, you are calling a method which assumes the datepicker has already been initialized on that object.

http://jsfiddle.net/tbYPf/4/

like image 123
John Koerner Avatar answered Nov 09 '22 06:11

John Koerner