I have a page with multiple input elements e.g.
<input data-default="2015-05-19 09:21:29" type="text" class="form-control datetimepicker">
This is my jQuery:-
$('input.datetimepicker').datetimepicker({locale:'en-gb', defaultDate:$(this).data('default')});
The default date part is not working, is there a better way to go about this?
[Heavily updated]. Seems to be a scope problem. $(this)
refers to the initialization object, not the input being datetimepickered'
$('input.datetimepicker').each(function(i, e) {
$(e).datetimepicker({
locale:'en-gb',
defaultDate: $(e).data('default')
});
});
demo -> http://jsfiddle.net/hdhdy6w2/ or http://jsfiddle.net/hdhdy6w2/1/ with two input boxes and different dates.