datepicker on dynamically created row with inputs

前端 未结 5 655
暗喜
暗喜 2021-02-08 14:47

I have a form which has the possibility to dynamically create new row with inputs, the date input on each new row should have a datepicker. I have this almost working, but when

5条回答
  •  暖寄归人
    2021-02-08 15:28

    Destroy the datepicker and create once again after added the new row. It will resolve the issue.

    Here is the example

    jQuery( ".datepick" ).datepicker(); //Add date picker.
    
    $('#addnew').click(function(){
       $(".datepick").datepicker("destroy"); //Distroy the date picker.
    
       /* Code to add a new row */
    
       jQuery( ".datepick" ).datepicker(); //recreating the date picker
    
    })
    

提交回复
热议问题