From 9757fb06db087f17670f8e9caf310b8ec585a977 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 12 Jun 2020 16:47:57 +1000 Subject: [PATCH] Fix a weird button issue - reloadTable() was causing the button 'click' handler to fire... - NFI why this is happening --- InvenTree/templates/js/barcode.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/InvenTree/templates/js/barcode.html b/InvenTree/templates/js/barcode.html index 7f4273d7eb..9c9a8c1b08 100644 --- a/InvenTree/templates/js/barcode.html +++ b/InvenTree/templates/js/barcode.html @@ -325,7 +325,7 @@ function barcodeCheckIn(location_id, options={}) { modalEnable(modal, false); // Remove click listeners - $(modal + ' .button-item-remove').off('click'); + $(modal + ' .button-item-remove').unbind('click'); var table = $(modal + ' #items-table-div'); @@ -361,18 +361,24 @@ function barcodeCheckIn(location_id, options={}) { $(modal + ' #barcode').focus(); - - $(modal + ' .button-item-remove').on('click', function() { + $(modal + ' .button-item-remove').unbind('click').on('mouseup', function() { var pk = $(this).attr('pk'); + var match = false; + for (var ii = 0; ii < items.length; ii++) { if (pk.toString() == items[ii].pk.toString()) { - //items.splice(ii, 1); + items.splice(ii, 1); + match = true; break; } } + + if (match) { + reloadTable(); + } - reloadTable(); + return false; }); }