gijgo icon indicating copy to clipboard operation
gijgo copied to clipboard

Events are triggered when opening the calendar

Open ablanco442 opened this issue 5 years ago • 4 comments

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

ablanco442 avatar Dec 06 '19 12:12 ablanco442

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.

refandhika avatar Feb 06 '20 15:02 refandhika

All the events fired twice (open/close/change/select). No solutions?

ezetojo avatar Mar 24 '20 15:03 ezetojo

Not as far as I know... had to do my own events :/

ablanco442 avatar Mar 24 '20 15:03 ablanco442

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;
  });

kieutrongthien avatar Jan 08 '24 09:01 kieutrongthien