From 830500a2bb969d9b8ce8e02afda89c5b3699f79b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 29 Jul 2016 16:19:48 +0200 Subject: [PATCH] Auto clear on form submit --- .../install/files/js/WoltLab/WCF/Ui/Redactor/Autosave.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Autosave.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Autosave.js index 94fffd21a9..2871bbc58f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Autosave.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Redactor/Autosave.js @@ -7,7 +7,7 @@ * @license GNU Lesser General Public License * @module WoltLab/WCF/Ui/Redactor/Autosave */ -define([], function() { +define(['Dom/Traverse'], function(DomTraverse) { "use strict"; // time between save requests in seconds @@ -38,6 +38,11 @@ define([], function() { // remove attribute to prevent Redactor's built-in autosave to kick in this._element.removeAttribute('data-autosave'); + + var form = DomTraverse.parentByTag(this._element, 'FORM'); + if (form !== null) { + form.addEventListener('submit', this.destroy.bind(this)); + } }, /** @@ -46,7 +51,7 @@ define([], function() { * * @return {string} message content */ - getInitialValue: function () { + getInitialValue: function() { var value = ''; try { value = window.localStorage.getItem(this._key); -- 2.20.1