gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

Change event fires when opening datepicker

Open tobifasc opened this issue 6 years ago • 2 comments

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.

tobifasc avatar Aug 13 '19 11:08 tobifasc

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.

carlos-mg89 avatar Feb 11 '20 12:02 carlos-mg89

So I've a workaround if it helps to someone. Basically, it does the following:

  1. Stores the value that is on the input field when JQuery is loaded
  2. Checks in the onChange event if the new value is different than the previous one
  3. 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();
    }
});

carlos-mg89 avatar Feb 11 '20 12:02 carlos-mg89