diff --git a/InvenTree/InvenTree/static/script/inventree/notification.js b/InvenTree/InvenTree/static/script/inventree/notification.js index f6bdf3bc57..c4816d4b5c 100644 --- a/InvenTree/InvenTree/static/script/inventree/notification.js +++ b/InvenTree/InvenTree/static/script/inventree/notification.js @@ -37,7 +37,6 @@ function showAlertOrCache(message, cache, options={}) { if (cache) { addCachedAlert(message, options); } else { - showMessage(message, options); } } @@ -82,6 +81,8 @@ function showMessage(message, options={}) { var timeout = options.timeout || 5000; + var target = options.target || $('#alerts'); + var details = ''; if (options.details) { @@ -111,7 +112,7 @@ function showMessage(message, options={}) { `; - $('#alerts').append(html); + target.append(html); // Remove the alert automatically after a specified period of time $(`#alert-${id}`).delay(timeout).slideUp(200, function() { diff --git a/InvenTree/templates/js/translated/forms.js b/InvenTree/templates/js/translated/forms.js index d5be70e4fe..c288ada27f 100644 --- a/InvenTree/templates/js/translated/forms.js +++ b/InvenTree/templates/js/translated/forms.js @@ -942,9 +942,22 @@ function handleFormSuccess(response, options) { cache = false; } + var msg_target = null; + + if (options.modal && options.reloadFormAfterSuccess) { + // If the modal is persistant, the target for any messages should be the modal! + msg_target = $(options.modal).find('#pre-form-content'); + } + // Display any messages if (response && (response.success || options.successMessage)) { - showAlertOrCache(response.success || options.successMessage, cache, {style: 'success'}); + showAlertOrCache( + response.success || options.successMessage, + cache, + { + style: 'success', + target: msg_target, + }); } if (response && response.info) {