I am working on a project, where at one point you have to add multiple dates. The Problem is that the Date & Time Pickers work on the first set of textboxes, won't work on any of the following, dynamically added textboxes.
Here is the whole Javascript Code(The different date & time pickers & the function to add additional textboxes):
<script type="text/javascript">
$(document).ready(function(){
$('.end').datetimepicker({
datepicker:false,
format:'H:i:s',
step:5
});
$('.start').datetimepicker({
datepicker:false,
format:'H:i:s',
step:5
});
$('.date').datetimepicker({
timepicker:false,
lang:'de',
format:'Y-m-d',
formatDate:'Y-m-d'
});
var counter = 2;
$("#addButton").click(function () {
if(counter>10){
alert("Only 10 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div'));
newTextBoxDiv.attr("id", 'TextBoxDiv'+counter);
newTextBoxDiv.attr("class", 'termin');
newTextBoxDiv.after().html('<label>Termin #'+ counter + ' : </label>' +
'<input type="textbox" class="date" name="datum' + counter + '">' +
'<input type="textbox" class="start" name="start' + counter + '">' +
'<input type="textbox" class="end" name="end' + counter + '">');
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
});
</script>