When attaching datetimepicker directly to the <input> element, selecting a date will trigger the onchange() event of the <input> as it should, however the datetimepicker doesn't work correctly (see https://github.com/Eonasdan/bootstrap-datetimepicker/issues/155 )
However when attaching datetimepicker to the <div> surrounding the <input> with a separate <span> for the date selection - as is the default configuration , selecting a date in the picker will NOT trigger the onchange event of the <input> - thus breaking any subsequent validation or onchange="submit()" features.
check the staging branch to see if your issue has been fixed
do you still have this issue with the latest version?
Seems not fixed to me:
<!-- Filter -->
<div class="filters">
<div class="form-group">
<label>Created at</label>
<div class="col-sm-8">
<input class="datepicker" name="created_at" type="text">
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
// Datepickers
$('input.datepicker').datetimepicker({
format: 'DD/MM/YYYY',
});
});
// Filters
$(document).on('change', 'div.filters input', function (e) {
alert('changed');
});
</script>
Alert is never prompted.
$(document).on('dp.change', 'input.datepicker', function() {
alert('changed');
});
should work
@jawu yes, it works.
Thanks.
the dp.change event also includes the current date and the previous date, by the way
not working dude
In version 4.17.37, 'change' event is not triggered on the input when a date is selected. It's true that on version 3.x 'change' was triggered when date was selected.
If you have listeners for 'change', just add 'dp.change' also:
$(inputSelector).on('change dp.change', function(e){
// do stuff...
})
Most helpful comment
should work