I have a div in which there is a datepicker. I use something like this to clone it:
mydiv = $(\'#someDiv\');
// works fine so far
mydiv.find(\'input.datefie
Here how it worked for me:
First you need to remove the class hasDatepickerfrom the cloned elements,because this is what is preventing the datepicker from getting attached to the specific element.
Then you gotta remove the id attribute from each of the cloned elements else .datepicker() will assume that datepicker is added to this element.
After that call .datepicker() on cloned element.
newDiv.find('.classAttributeGivenForDatepicker').each(function() {
$(this).removeAttr('id').removeClass('hasDatepicker');
$(this).datepicker({dateFormat: 'dd-mm-yy', minDate: 0, autoclose: true,});
});