GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

Question: Is it required to unbind events on Destroy #425

Closed mallikarjuna909 closed 7 years ago

mallikarjuna909 commented 7 years ago

Hi, Is it required to unbind events on Destroy like ContentEdit.Root.get().unbind('paste', this._handleClipboardPaste) on _EditorApp.prototype.destroy ?

Thanks.

mallikarjuna909 commented 7 years ago

Hi, I think it is required because some event handlers are being called several times if we don't unbind events. As per this comment i got "when you destroy the editor you remove it from the DOM but that doesn't itself remove existing event bindings you have against the editor".

Please correct me and confirm, so that i can close this question.

anthonyjb commented 7 years ago

Hi @mallikarjuna909,

If you bind events to the ContentEdit element Root element then you will need to also unbind these before you re-apply them (e.g through listening to the editor start event etc).

Ant

mallikarjuna909 commented 7 years ago

Hi @anthonyjb

Thanks for your kind reply. My doubt is clarified. Hence closed.