From: Andrew Lorimer Date: Sat, 17 Aug 2019 13:35:13 +0000 (+1000) Subject: fix event listener bug for items & add buttons X-Git-Url: https://git.lorimer.id.au/newtab.git/diff_plain/a5b13dad7a3dda4460e3589aadaa0bae73ca1e31 fix event listener bug for items & add buttons --- diff --git a/admin.js b/admin.js index 224e692..ea20d86 100644 --- a/admin.js +++ b/admin.js @@ -168,6 +168,7 @@ function drop(e) { dragSrcEl.innerHTML = this.innerHTML; this.innerHTML = e.dataTransfer.getData('text/html'); save(); + menu(); } return false; } @@ -314,7 +315,7 @@ function listen(li) { } else { addItem(r, li); } - }, false); + }, true); } function addItem(caller, li) { @@ -380,12 +381,14 @@ function addItem(caller, li) { span.onmouseout = function() { this.style.background = hoverbg2; }; + menu(); // TODO fix bug where form save button loses its eventlistener after generating form for another column twice fields = document.querySelector("#"+id+" .new .name"); fields.focus(); } function menu() { + // Update event listeners for all items, their remove buttons, and the add button for each column var allUserLi = document.querySelectorAll('.remove, .add'); allUserLi.forEach(function(li, p_index){