jtsage / jtsage-datebox

A multi-mode date and time picker for Bootstrap (3&4), jQueryMobile, Foundation, Bulma, FomanticUI, and UIKit (or others)
http://datebox.jtsage.dev/
Other
474 stars 166 forks source link

Destroy method can cause huge loops #404

Closed sigmapi closed 7 years ago

sigmapi commented 7 years ago

Hi and thanks again for this project!

I've encountered two bugs in _destroy method:

  1. button.remove(); line, can lead to endless loop, as destroy event is triggered again and _destroy method ends up called again and again. My fix is to remove the button's event listeners first: button.off(); button.remove();

  2. w.d.mainWrap.popup("destroy"); line, can cause an error to be thrown, if there is an inactive popup. My fix is to wrap it to a try/catch: try { w.d.mainWrap.popup("destroy"); } catch (e) { }