gijgo
gijgo copied to clipboard
Events are triggered when opening the calendar
Hi, I'm trying to use the select or change event, however they trigger in the second I open the calendar, and it executes the event twice when opening
Hi, i just got across similar problem with datepicker.
I found out if we try to trigger open() method
picker.value(picker.element.value); // This line trigger change
I currently comment this out, seems everything work fine for now. Except the box background color on the default day become none.
All the events fired twice (open/close/change/select). No solutions?
Not as far as I know... had to do my own events :/
You can try to define a bool variable called opened , let try the code below:
var opened = false;
$('#attr_disabled_dates').datepicker({
uiLibrary: 'bootstrap5',
format: 'yyyy-mm-dd'
});
$('#attr_disabled_dates').on('open', function(e) {
opened = true;
})
$('#attr_disabled_dates').on('change', function(e) {
if(!opened) return;
console.log(e.target.value);
opened = false;
});