Vasethvan
Vasethvan

Reputation: 411

Issue in jquery.datetimepicker.js when used on a dynamically appended text box

I am using jquery.datetimepicker.js plugin to get date time picker in form field.

<input type="text" class="datetimepicker" placeholder="Please Select" />

As mentioned above, I can get the calender popup while clicking on the text box. Based on my project requirement, I am appending one text box and adding the 'datetimepicker' class underneath the above html tag in order to get the calender popup. But the problem is, if I am dynamically adding the class on the text box I am unable to get the calender window.

Is there any issue with dynamically appended text boxes? How can I initiate the entire calender plugin?

Upvotes: 0

Views: 161

Answers (1)

mccannf
mccannf

Reputation: 16659

You initialize it when dynamically appending the input field. E.g.

var newpicker = $('<input type="text" class="datetimepicker" placeholder="Please Select" />');
newpicker.appendTo("#id_of_some_div");
newpicker.datetimepicker();

Upvotes: 1

Related Questions