Choosing files

Choosing files with CKBox is possible using the assets.onChoose configuration option, which takes a callback executed after files are chosen. If this option is defined, Choose button will be visible in CKBox. After selecting assets and clicking the Choose button, the callback is defined in assets.onChoose will receive an array of objects representing chosen assets. To read more about these objects’ structure and available helper methods, please refer to the description of assets.onChoose option.

CKBox.mount(document.querySelector('#ckbox'), {
    tokenUrl: 'https://your.token.url',
    dialog: true,
    assets: {
        // Callback executed after choosing assets
        onChoose: (assets) => {
            assets.forEach((asset) => {
                console.log(asset.data.url);
            })
        }
    }
});

Click the button below to open CKBox in dialog mode. URLs of the chosen files will be logged in the console.