Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.
Forum Discussion
Nihad1
2 years agoExplorer | Level 4
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
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
2 Replies
- Здравко2 years agoLegendary | Level 20
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-DB2 years ago
Dropbox Community Moderator
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
Make connections with other developers815 PostsLatest Activity: 4 years ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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!