UploadCare does not display warning when closing dialog
When the UploadCare dialog is closed, I expect a warning to appear, but it is not. Why not? '
$('#uc_open').on('click', function() {
uploadcare.openDialog(null, {
imagesOnly: true
}).done(function(file) {
file.done(function(fileInfo) {
//
}).fail(function(error, fileInfo) {
alert(error);
});
});
return false;
});
source to share
You are subscribed to openDialog().done()
. This callback will be called when the user selects a file and clicks "done" in the dialog. In this callback, you get the object file
and subscribe to the callback file.fail()
. This callback will be called when a file upload is done due to a network error or poor validators.
If you want to subscribe to the callback when the user closes the dialog without selecting a file (by clicking the × in the upper right corner or pressing ESC), you must subscribe to openDialog().fail()
:
$('#uc_open').on('click', function() {
// Open the dialog on button cick
uploadcare.openDialog(null, {
imagesOnly: true
}).done(function(file) {
// User has just clicked "Done" in Uploadcare dialog
file.done(function(fileInfo) {
// File uploading succeeded
});
}).fail(function(error, fileInfo) {
// User just has closed the dialog by pressing ESC or clicking on "×"
alert(error);
});
return false;
});
source to share