From 5230a5a41b5b23306759d7624b4d30b7ce1cd0e9 Mon Sep 17 00:00:00 2001 From: Oliver <oliver.henry.walters@gmail.com> Date: Tue, 29 Jun 2021 19:55:32 +1000 Subject: [PATCH] Add "success" functionality for form posting --- InvenTree/templates/js/forms.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index dd72031149..8c74def263 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -490,11 +490,21 @@ function handleFormSuccess(response, options) { $(options.modal).modal('hide'); } - if (response.url) { - // GOTO - window.location.href = response.url; + if (options.onSuccess) { + // Callback function + options.onSuccess(response, options); } + if (options.follow && response.url) { + // Follow the returned URL + window.location.href = response.url; + } else if (options.reload) { + // Reload the current page + location.reload(); + } else if (options.redirect) { + // Redirect to a specified URL + window.location.href = options.redirect; + } }