Link that will save the post before leaving
-
How can I use a link that will save the post before leaving?
I tried this:
link.onclick = function() { wp.data.dispatch("core/editor").savePost(); location.href = myUrl; }
but I still get the javascript alert (“Leave site? Changes you made may not be saved.”)
This is working but very slow and poor experience:
link.onclick = function(e) { e.preventDefault(); wp.data.dispatch("core/editor").savePost(); setTimeout(function() { location.href = myUrl; }, 2000); }
Any better solution?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Link that will save the post before leaving’ is closed to new replies.