mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-01 21:42:28 +02:00
Merge pull request #2 from adamb70/fix-autosave-submit-handler
Update src/js/easymde.js
This commit is contained in:
commit
613fb0fcad
|
@ -1655,11 +1655,23 @@ EasyMDE.prototype.autosave = function () {
|
||||||
console.log('EasyMDE: You must set a uniqueId to use the autosave feature');
|
console.log('EasyMDE: You must set a uniqueId to use the autosave feature');
|
||||||
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();
|
||||||
|
}, 10000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options.autosave.binded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.autosave.loaded !== true) {
|
if (this.options.autosave.loaded !== true) {
|
||||||
|
|
Loading…
Reference in a new issue