diff --git a/src/editor.js b/src/editor.js index 5a8d0728..c155ab68 100644 --- a/src/editor.js +++ b/src/editor.js @@ -133,6 +133,7 @@ * Deactivate editor (make it readonly) */ disable: function() { + this.synchronizer.disable(); this.currentView.disable(); return this; }, diff --git a/src/views/synchronizer.js b/src/views/synchronizer.js index b28855fa..a572fe9b 100644 --- a/src/views/synchronizer.js +++ b/src/views/synchronizer.js @@ -51,6 +51,14 @@ } }, + /** + * Deactivate editor (make it readonly) + */ + disable: function() { + this._domObserveSubmit.stop(); + this._domObserveReset.stop(); + }, + /** * Initializes interval-based syncing * also makes sure that on-submit the composer's content is synced with the textarea @@ -73,10 +81,10 @@ if (form) { // If the textarea is in a form make sure that after onreset and onsubmit the composer // has the correct state - wysihtml5.dom.observe(form, "submit", function() { + this._domObserveSubmit = wysihtml5.dom.observe(form, "submit", function() { that.sync(true); }); - wysihtml5.dom.observe(form, "reset", function() { + this._domObserveReset = wysihtml5.dom.observe(form, "reset", function() { setTimeout(function() { that.fromTextareaToComposer(); }, 0); }); }