I use nice simple datepicker for twitter bootstrap http://www.eyecon.ro/bootstrap-datepicker/
<div class="input-append datepick">
<input size="16" type="text">
<span class="add-on"><i class="icon-th"></i></span>
</div>
I trying to clone div with datepicker:
$('#addButton').click(function() {
var newStr = $("#makeList").find(".additem-block").last().clone(true).appendTo("#makeList");
newStr.find(".datepick").each(function() {
$(this).attr("id", "").removeData('datepicker').unbind();
$(this).val('');
$(this).datepicker();
});
});
When I click on datepicker button it's open datepicker div at two places: over the original button and over cloned button.
How to clone it properly?
3 hours of experiments yielded the result:
newStr.find(".datepick").each(function() {
$(this).attr("id", "").removeData().off();
$(this).find('.add-on').removeData().off();
$(this).find('input').removeData().off();
$(this).datepicker();
});
Not beautiful, but works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With