I am using bootstrap datepicker in my page.
The form in which I am using this has multiple datepickers generated dynamically.
Now case is when you click first input element and select date then it works for that input field,
Now add another element and click in that input field. The datepicker does not initialize properly.
It works fine if you first add elements and click in the inputs..
Here is what I've tried so far..
$(function() {
var addMilIterator = 0;
$(document).on('click', '[data-ele="addMil"]', function(e) {
var clone = $('.milestones-form').first().clone(true);
$(clone).find('[name]').each(function() {
var name = $(this).attr('name');
$(this).val("");
$(this).attr('name', name + '_' + addMilIterator);
});
addMilIterator++;
$('.milestones-form').last().after(clone);
});
$(document).on('focus', '[name^="date"]', function() {
$(this).datepicker({
})
});
});
I've created a fiddle for that if it helps. Any hint will do. Link to fiddle
Please don't give negative remarks just because my editing is poor. Thanks everybody...