From 1b31c5fc90cb2d3801909aa94b17bf956565e7e9 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 7 May 2021 17:44:24 +0200 Subject: [PATCH] keep the spinner visible while the image loads --- htdocs/lib/settings/ImageUpload.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/lib/settings/ImageUpload.js b/htdocs/lib/settings/ImageUpload.js index 29acd8e..2337318 100644 --- a/htdocs/lib/settings/ImageUpload.js +++ b/htdocs/lib/settings/ImageUpload.js @@ -54,6 +54,10 @@ $.fn.imageUpload = function() { contentType: 'application/octet-stream', }).done(function(data){ $input.val(data.file); + $img.one('load', function() { + $uploadButton.prop('disabled', false); + $spinner.remove(); + }); $img.prop('src', '../imageupload?file=' + data.file); clearError(); }).fail(function(xhr, error){ @@ -63,7 +67,6 @@ $.fn.imageUpload = function() { } catch (e) { handleError(error); } - }).always(function(){ $uploadButton.prop('disabled', false); $spinner.remove(); });