Nes Nes - 1 month ago 5
jQuery Question

"inst is undefined" error in jQuery UI Datepicker

I basically have a jQuery Datepicker. The Datepicker shows up but it doesn't seem functional as it does nothing when a day is selected. It doesn't work and previous and next are selected as well.

I get the "inst is undefined" error

-- the script

jQuery(function() {
jQuery("#datepicker1").datepicker();
});


-- the element

<input type="text" id="datepicker1" name="datepicker1"/>

Nes Nes
Answer

I found the answer.

There is a part in the page that copies the form where the element datepicker1 is included. Thus, there were multiple "datepicker1" being generated. The datepicker gets confused with the multiple datepicker1 and perhaps gets the value of the one with no value at all.

I did a fix by naming my datepicker input uniquely

<?php $x++; ?>
<input type="text" id="datepicker<?=$x;?>" name="datepicker1"/>

If you have the same problem, you might just need to make sure that all your datepickers have unique id.

Comments