Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter bootstrap datepicker clone

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?

like image 455
memtew Avatar asked Sep 18 '26 14:09

memtew


1 Answers

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.

like image 141
memtew Avatar answered Sep 20 '26 04:09

memtew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!