brospars / simple-calendar

Simple calendar jquery plugin
https://brospars.github.io/simple-calendar
MIT License
49 stars 38 forks source link

Empty only empties the calendar month view but not the events #44

Closed djcaesar9114 closed 2 years ago

djcaesar9114 commented 2 years ago

Hello, First of all thanks for your work. When I write this:

container.empty().data('plugin_simpleCalendar', null).simpleCalendar({
    displayEvent: true,
    events: events
  });

It refreshed the events in the month view (the blue dots appear on the correct dates) but the previous events remain the same: if I click on a date when there was an event, I can still see it in the list of the events of the day.

I tried to solve this issue: https://stackoverflow.com/questions/69754113/is-there-a-way-i-can-empty-my-object-to-make-new-dates-able-to-be-inserted-ont/69755768#69755768

brospars commented 2 years ago

Hello, First of all thank you for reporting this issue and helping on stackoverflow.

The problem is that .empty() doesn't remove delegated events from the container (e.g. those events) so you need to call .off() in addition of .empty().

I fixed it in the commit mentioned above. I have also added a method to set events without the need to reset the whole calendar.