Maximilian
Lifer
Im using this datepicker:
https://github.com/eternicode/bootstrap-datepicker/blob/master/docs/events.rst
Its really good, I want things to happen when the datepickers date is changed so I put in this code for when the datepickers changeDate event fires:
It works great but it only works if its placed after the datepicker in the HTML document. I get that I cant mess with elements that haven't been created/loaded yet but surely the datepicker must be loaded in order for a changeDate event to be fired? Why does that code not work if placed in the <head> tags before the datepicker declaration?
Thats the datepicker declaration in case its relevant:
https://github.com/eternicode/bootstrap-datepicker/blob/master/docs/events.rst
Its really good, I want things to happen when the datepickers date is changed so I put in this code for when the datepickers changeDate event fires:
Code:
<script>
$('#aDatepicker').datepicker().on('changeDate', function () {
var newDate = $("#aDatepicker").datepicker("getDate");
currentDate = newDate;
});
</script>
It works great but it only works if its placed after the datepicker in the HTML document. I get that I cant mess with elements that haven't been created/loaded yet but surely the datepicker must be loaded in order for a changeDate event to be fired? Why does that code not work if placed in the <head> tags before the datepicker declaration?
Thats the datepicker declaration in case its relevant:
Code:
<div class="input-group date" id="aDatepicker">
<input type="text" class="form-control" id="aDatepickerTextBox"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
</div>