2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-19 07:54:28 -06:00

Merge pull request #31 from adamb70/master

Fix autosave event handler
This commit is contained in:
Jeroen Akkerman 2018-11-09 10:40:50 +01:00 committed by GitHub
commit 604f2c8ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1657,10 +1657,22 @@ EasyMDE.prototype.autosave = function () {
return; return;
} }
if (easyMDE.element.form != null && easyMDE.element.form != undefined) { if(this.options.autosave.binded !== true) {
easyMDE.element.form.addEventListener('submit', function () { if (easyMDE.element.form != null && easyMDE.element.form != undefined) {
localStorage.removeItem('smde_' + easyMDE.options.autosave.uniqueId); easyMDE.element.form.addEventListener('submit', function () {
}); clearTimeout(easyMDE.autosaveTimeoutId);
easyMDE.autosaveTimeoutId = undefined;
localStorage.removeItem('smde_' + easyMDE.options.autosave.uniqueId);
// Restart autosaving in case the submit will be cancelled down the line
setTimeout(function() {
easyMDE.autosave();
}, easyMDE.options.autosave.delay || 10000);
});
}
this.options.autosave.binded = true;
} }
if (this.options.autosave.loaded !== true) { if (this.options.autosave.loaded !== true) {