gijgo
gijgo copied to clipboard
Change event fires when opening datepicker
When opening a datepicker that already contains a valid (unchanged) date dayClickHandler is called inside of the method value which causes a change event if the datepickers footer is disabled and autoClose is true. Instead only an open event should be fired.
Still happening and it's a bit frustrating. I'm gonna try to detect the change event when a day is selected instead, analysing the DOM. Will post back if I succeed.
So I've a workaround if it helps to someone. Basically, it does the following:
- Stores the value that is on the input field when JQuery is loaded
- Checks in the onChange event if the new value is different than the previous one
- In my case, after a new date is set, I submit the form
let currentStartDate = $('#startDate').val();
$('#startDate').on('change', function() {
if ($(this).val() != currentStartDate) {
$("#ingredients-filters-form").submit();
}
});