Events

When initializing the SDK frame, a number of events can be passed to the configuration, which will be executed at the appropriate moment:

Events and their description:

  • onAppError - the function called when SDK is initialized with an error. This error is returned during the initialization.

    Example
    var onAppError = function () {
        console.log("ONLYOFFICE DocSpace reports an error");
    };
    
    var docSpace = DocSpace.SDK.initManager({
        "events": {
            "onAppError": null,
            ...
        },
        ...
    });
    
  • onAppReady - the function called when SDK is initialized successfully.

    Example
    var onAppReady = function () {
        console.log("ONLYOFFICE DocSpace is ready");
    };
    
    var docSpace = DocSpace.SDK.initManager({
        "events": {
            "onAppReady": null,
            ...
        },
        ...
    });
    
  • onCloseCallback - the function called only in the room-selector and file-selector modes when the room or file selector is closed or the selection is canceled.

    Example
    var onCloseCallback = function () {
        console.log("The room selector is closed.");
    };
    
    var docSpace = DocSpace.SDK.initRoomSelector({
        "events": {
            "onCloseCallback": null,
            ...
        },
        ...
    });
    
  • onSelectCallback - the function called only in the room-selector and file-selector modes when a room or file is selected.

    Example
    var onSelectCallback = function () {
        console.log("The 'New room' room was selected.");
    };
    
    var docSpace = DocSpace.SDK.initRoomSelector({
        "events": {
            "onSelectCallback": null,
            ...
        },
        ...
    });
    

    The information about the selected item is returned:

    {
        "icon": "https://example.com/url-to-example-image.svg",
        "id": 34,
        "isSelected": false,
        "label": "roomName"
    }
    

    where example.com is the name of the server with the ONLYOFFICE DocSpace installed.

    Parameter Description Type Presence
    icon Defines the URL to the room/file icon. string required
    id Defines the room/file ID. integer required
    isSelected Specifies whether the current room/file is selected. boolean required
    label Defines the room/file label. string required