Save document using onRequestClose method

Post Reply
Philippe
Posts: 4
Joined: Tue Mar 09, 2021 4:22 pm

Save document using onRequestClose method

Post by Philippe » Tue Mar 16, 2021 2:38 pm

Hello,

We use onRequestClose method to close the editor :
  • Is there a way to know if the document has changed but not saved ?
  • Is there a way to save the document ?
Thanks.

Carl
Posts: 616
Joined: Thu Apr 12, 2018 10:00 am

Re: Save document using onRequestClose method

Post by Carl » Tue Mar 16, 2021 4:15 pm

Hello Philippe,

By default, document saving happens when the last co-editor closes the editor tab in the browser (in your case the last user who initiates the destroyEditor method by clicking the Close button).
You can learn more here:
https://api.onlyoffice.com/editors/save

If you need to manually trigger file saving, you can implement the forcesave:
https://api.onlyoffice.com/editors/save#forcesave

Information about the document being changed or ready to be saved is sent by the Document Server via status messages to the callback handler (status 1 and 2 respectively):
https://api.onlyoffice.com/editors/callback#status

Philippe
Posts: 4
Joined: Tue Mar 09, 2021 4:22 pm

Re: Save document using onRequestClose method

Post by Philippe » Fri Mar 19, 2021 3:07 pm

We've decided to go with auto save.
However, in the onResquestClose method, we should be able to tell the browser to alert the user that the document has changed. The browser does it by itself when the onRequestClose method is not implemented. That would leave the user a chance not to save the document. Any idea?

Post Reply