keep the spinner visible while the image loads

This commit is contained in:
Jakob Ketterl 2021-05-07 17:44:24 +02:00
parent 0206a6f94c
commit 1b31c5fc90

View File

@ -54,6 +54,10 @@ $.fn.imageUpload = function() {
contentType: 'application/octet-stream', contentType: 'application/octet-stream',
}).done(function(data){ }).done(function(data){
$input.val(data.file); $input.val(data.file);
$img.one('load', function() {
$uploadButton.prop('disabled', false);
$spinner.remove();
});
$img.prop('src', '../imageupload?file=' + data.file); $img.prop('src', '../imageupload?file=' + data.file);
clearError(); clearError();
}).fail(function(xhr, error){ }).fail(function(xhr, error){
@ -63,7 +67,6 @@ $.fn.imageUpload = function() {
} catch (e) { } catch (e) {
handleError(error); handleError(error);
} }
}).always(function(){
$uploadButton.prop('disabled', false); $uploadButton.prop('disabled', false);
$spinner.remove(); $spinner.remove();
}); });