In This Topic
Reference Guides / JavaScript API / Events / RegisterOnDocumentSaved

RegisterOnDocumentSaved

In This Topic
 RegisterOnDocumentSaved

This function allows you to trigger a function of your own when the document save event is fired.

RegisterOnDocumentSaved: function (docuViewareID, callback)

Parameters

docuViewareID
The identifier for the DocuVieware™ instance.
callback
The function you want to execute on event.

Return Value

1 if error.

Example of usage

This JavaScript makes sure the DocuVieware control is properly loaded and initialized and then subscribes to the event on load.

function RegisterOnDocumentSavedOnDocuViewareAPIReady() {
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
        DocuViewareAPI.RegisterOnDocumentSaved("DocuVieware1", function () { console.log("document saved"); });
    }
    else {
        setTimeout(function () { RegisterOnDocumentSavedOnDocuViewareAPIReady() }, 10);
    }
}
document.addEventListener("DOMContentLoaded", function () {
    RegisterOnDocumentSavedOnDocuViewareAPIReady();
}, false);