jquery - Datetimepicker did not work on element that append form javascript -
i have 1 input date, input append js this
var inputdate = '<input type="text" name="date[]" class="form-control date" placeholder="input date"'; $("form").append(inputdate);
and html code :
<form method="post"> ... </form>
initialize datetimepicker
$('.date').datetimepicker({ format: 'yyyy-mm-dd' });
the input element append succesfully , other form have input date work datetimepicker. element append js not showing datetimepicker, there mistakes?
i think missed 1 thing here.
var inputdate = '<input type="text" name="date[]" class="form-control date" placeholder="input date"';
it should have >
@ end of string.
the initialization code should reexecuted after append inputdate
$('form')
.
so code should be:
var inputdate = '<input type="text" name="date[]" class="form-control date" placeholder="input date">'; $("form").append(inputdate); $('.date').datetimepicker({format: 'yyyy-mm-dd'});
Comments
Post a Comment