From d44ad541ebf26a3d728bdeafb3d2425a727e4cd5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 26 Aug 2020 22:35:36 +1000 Subject: [PATCH] Add "callback" functionality for modal forms when a given field is changed - Attach callback function - Add a function to retrieve a field by name --- .../static/script/inventree/modals.js | 45 +++++++++++++++++++ InvenTree/stock/templates/stock/location.html | 8 ++++ 2 files changed, 53 insertions(+) diff --git a/InvenTree/InvenTree/static/script/inventree/modals.js b/InvenTree/InvenTree/static/script/inventree/modals.js index 5b76203927..83fdbd1bb1 100644 --- a/InvenTree/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/InvenTree/static/script/inventree/modals.js @@ -397,6 +397,13 @@ function injectModalForm(modal, form_html) { } +function getFieldByName(modal, name) { + /* Find the field (with the given name) within the modal */ + + return $(modal).find(`#id_${name}`); +} + + function insertNewItemButton(modal, options) { /* Insert a button into a modal form, after a field label. * Looks for a