From 291149d73339288896e6ec86985321311429777c Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 2 Jul 2021 17:46:54 +1000 Subject: [PATCH] New modal forms automatically work themselves out --- InvenTree/templates/js/modals.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/modals.js b/InvenTree/templates/js/modals.js index 8e32045c19..66f31a7f42 100644 --- a/InvenTree/templates/js/modals.js +++ b/InvenTree/templates/js/modals.js @@ -6,13 +6,22 @@ */ function createNewModal(options={}) { - var id = options.id || 0; - // Always increment the ID of the modal - id += 1; + var id = 1; + + // Check out what modal forms are already being displayed + $('.inventree-modal').each(function() { + var split = this.id.split('-'); + console.log('existing form:', split); + var modal_id = parseInt(split[2]); + + if (modal_id >= id) { + id = modal_id + 1; + } + }); var html = ` -