Merge pull request #31 from adamb70/master

Fix autosave event handler
pull/54/head
Jeroen Akkerman 6 years ago committed by GitHub
commit 604f2c8ea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1656,11 +1656,23 @@ EasyMDE.prototype.autosave = function () {
console.log('EasyMDE: You must set a uniqueId to use the autosave feature');
return;
}
if (easyMDE.element.form != null && easyMDE.element.form != undefined) {
easyMDE.element.form.addEventListener('submit', function () {
localStorage.removeItem('smde_' + easyMDE.options.autosave.uniqueId);
});
if(this.options.autosave.binded !== true) {
if (easyMDE.element.form != null && easyMDE.element.form != undefined) {
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) {

Loading…
Cancel
Save