Datetimepicker not calling/binding properly after removing dynamic input field

Datetimepicker not calling/binding properly after removing dynamic input field

I am using jquery datetimepicker with the following version

JQuery v1.7.2 JQuery UI - v1.10.3 jQuery timepicker addon V1.3

In a module, I am creating input field dynamically by clicking "+" as well as binding the datetimepicker for those input which are created dynamically as well as removing that input field by clicking "-".

My dynamic input fields always create like below:

datepickerfrom_1_1 datepickerfrom_1_2 datepickerfrom_1_3 datepickerfrom_1_4 datepickerfrom_1_5 . . .

I am binding the datetimepicker by using jQuery like below:

$(window).load(function() { $('body').on('focus', 'input[id^="datepickerfrom"]', function() { // Id's Containing "datepickerfrom" string, bind the datetimepicker $(this).datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'HH:mm:ss' }); }); }); 

The script(datetimepicker) is working fine when dynamic input is created.

Issue: I am adding some dynamic input field by clicking "+", then I removed some of the inputs by clicking "-", again I am adding some dynamic input fields. The second time created input field not calling/binding the datetimepicker properly.

What might be the issue? How can I solve it?