We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

Nihad1's avatar
Nihad1
Explorer | Level 4
6 months ago

is there is any option for callback after successfully embedded

$('#userGuideModal').on('show.bs.modal', function (e) {
    // Show the preloader
    $('#preloader').show();

    var scriptLoaded = false;

    // Check if Dropbox script is already loaded
    if (!document.getElementById('dropboxjs')) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.id = 'dropboxjs';
        script.dataset.appKey = 'KEY';

        script.onload = function() {
            console.log('Dropbox script loaded successfully.');
            scriptLoaded = true;
            embedDropboxContent();
        };

        script.onerror = function() {
            console.error('Error loading Dropbox script.');
            $('#preloader').hide();
        };

        document.body.appendChild(script);

        // Set a timeout to handle cases where the script doesn't load
        setTimeout(function() {
            if (!scriptLoaded) {
                console.error('Dropbox script loading timed out.');
                $('#preloader').hide();
            }
        }, 5000); // Adjust the timeout duration as needed
    } else {
        scriptLoaded = true;
        embedDropboxContent();
    }
});

function embedDropboxContent() {
    var element = document.getElementById('dropbox-embedder-container');
    var options = {
        link: "URL",
        file: {
            zoom: "best"
        },
        folder: {
            view: "list",
            headerSize: "normal"
        },
        success: function() {
            console.log('Dropbox content embedded successfully.');
            // Hide the loader when embedding is successful
            $('#preloader').hide();
        },
        error: function(errorMessage) {
            console.error('Error embedding Dropbox content:', errorMessage);
            // Hide the loader on error
            $('#preloader').hide();
        }
    };
    Dropbox.embed(options, element);
}


there is a delay before i frame appending to div, so i want to show a preloader, once append completed i want to remove the preloader, so i was trying with 'success' function, but its not working as expected
 
  • Hi Nihad1,

    There is not such a callback. Though, you can do it in the same way as you have it partially done already actually. 😉 Take a look here for an example.

    Hope this gives direction.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Nihad1 The Dropbox Embedder itself does not support success or error callbacks, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

     

    As Здравко mentioned however, you can monitor for changes to your element directly.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API

Make connections with other developers

795 PostsLatest Activity: 5 days ago
192 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!