3

I'm using following code to force WordPress page to save post as draft, is there any callback function for it, I want to alert a text after it complete saving post as draft.

if ( wp.autosave.server ) {
wp.autosave.server.triggerSave();
}
6

So I found the solution, callback function for when post or page is:

jQuery(document).on('heartbeat-tick.autosave', function( event, data ) {
    // your code here
});

This uses the Wordpress Heartbeat API.

| improve this answer | |
  • 1
    Yes. Here is WordPress Heartbeat API which allows to send any additional data to the server. I thought to write a detailed response but it seems you already solve your issue :) – Kolya Korobochkin Aug 24 '16 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.