hi
i copied the code from your docs but the change events are not being fired - any reason you can think of that might cause this?
thanks
:)
Hi, same is happening here.
Any possible idea?
Thanks
i've tried everything i can think of but no luck - not sure if it's an incompatibility with new jquery or moment or a bug in the datetime picker itself
hoping for some progress toward a fix soon or i have to dump this and use something else
I'm getting this as well.. it seems to be that on line 483 that the date and old date are the same and its not firing the event.
if (e.type === 'dp.change' && ((e.date && e.date.isSame(e.oldDate)) || (!e.date && !e.oldDate)))
it seems that 'unset' online 861 is always false so its making the oldDate always equal to the new date.
var oldDate = unset ? null : date;
dp.change will never be fired.
I'm investigating more.
It works me. Do check that you are listening on the right element.
This is what I am using to update the value of some date field when some other date field changes:
HTML
<div class="form-group date_picker required reservation_date">
<div class="input-group date datetimepicker">
<input class="form-control string date_picker required " type="text" value="24/01/2017" name="reservation[date]" id="reservation_date">
<span class="input-group-btn">
<button class="btn btn-default" type="button">
<span class="fa fa-calendar"></span>
</button>
</span>
</div>
</div>
JS
$('.datetimepicker').datetimepicker({
// put here your custom picker options, that should be applied for all pickers
icons: {
date: 'fa fa-calendar',
time: 'fa fa-clock-o',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-crosshairs',
clear: 'fa fa-trash-o',
close: 'fa fa-times'
}
});
$('.reservation_date .datetimepicker').on('dp.change', function() {
$('.reservation_first_day .datetimepicker').data("DateTimePicker").date($(this).data("DateTimePicker").date())
})
so the event comes from the datetimepicker within the element?
slaps head
thanks i will try this
@fake-fur I added the HTML code to the example, in case you want to compare.
It shouldn't be relevant but, in my case I am using input-group-btn instead of input-group-addon – I edited the datepicker js file to support this.
thanks will try later when home from office :)
Trying to attach to an input. I cannot get this to work.
$('input[name="start-date"],input[name="end-date"]').datetimepicker({
format: 'DD MMMM YYYY'
}).on('dp.change', function(e) {
console.log('changed');
});
I found if I used the most recent release 4.17.46 it is working.
Also try attaching to the input with an ID.
@Gnative Thanks. Am on the latest version, and tried with IDs, but still no luck.
Hi, actually seems like this issue was happening in the latest version.
My code was working fine with the older version but it just stopped working after updating the plugin.
I workaround that I found in order to trigger the change event was setting a new date (could be the same as the initial one) by using the function .date()
Note: you should call it after the datepicker is initialized.
It's not an elegant solution but so far I didn't found any other way.
Using jQuery v2 instead of v3 "fixes" this for me on release v4.17.46.
This not work:
$(".date").on("dp.change", function(e){
//doesnt work
});
This work:
$(".parent_div").on("dp.change", ".date", function(e){
//works
});
Does #1942 (included in v4.17.47) fix this?
@lasseal This is happening to me as well, I'm on 4.17.47 but my JQuery is is an oldy, 1.12. Maybe upgrading to JQuery v2? Did you have any luck solving this?
"eonasdan-bootstrap-datetimepicker": "^4.17.47",
"jquery": "^3.1.1"
Works like a charm together.
Hi, the latest version, 4.17.47, doesn't have this error.
In my case the dp.change event was not firing because the dp.error event fires instead. When the dp.error event fires, the dp.change event does not fire at all.
I am using bootstrap datetime picker. After doing lots of research, below code works for me:
$('.data_date_of_birth').on('changeDate', function(event) {
alert($(this).val());
});
Most helpful comment
It works me. Do check that you are listening on the right element.
This is what I am using to update the value of some date field when some other date field changes:
HTML
JS