Search code examples
phptinymceautosave

TinyMCE: Autosave Plugin & Ajax


I am using the Autosave Plugin:

This plugin gives the user a warning if they made modifications to the content within an editor instance but didn't submit the changes.

I use the plugin like this:

tinymce.init({
         selector: '#about',
         plugins: "table autoresize autosave link image",
});

If I change the content and try to leave the page I get a warning message as expected. However, if the user clicks the save button then the content is stored with ajax. The plugin still believes that the changes have not been submited yet.

Is there anyway how I can tell the autosave plugin that changes have been saved succesfully after the ajax call?


Solution

  • You can use the built-in save function of TinyMCE's editor which will let the autosave plugin know that the content has been saved.

    tinymce.get('about').save();
    

    Demo: https://jsfiddle.net/xv93x8cm/1/
    For more information: https://www.tinymce.com/docs/api/tinymce/tinymce.editor/