kthornbloom/Monthly

Duplicated Click events

Closed this issue · 3 comments

Well...

When i load the monthly plugin on a div works ok, but if i load again the webpage (by ajax) and reinitialize the plugin on the same div (now empty because it was loaded by ajax) the plugin shows up correctly but when i click on any button the click event fires 2 times.

Yeah, it's a known bug. Please see discussion here for a (hackish) workaround: #4

Try removing the click events before reinitializing:

$(document.body).off('click', '#mycalendar .monthly-next');
$(document.body).off('click', '#mycalendar .monthly-prev');
$(document.body).off('click', '#mycalendar .monthly-reset');
$(document.body).off('click', '#mycalendar .monthly-cal');
$(document.body).off('click', '#mycalendar a.monthly-day');
$(document.body).off('click', '#mycalendar .listed-event');

@devlinhaines01 Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It works perfectly now!