From 44c4381164f2a8afbe770a68bfaaab2398008145 Mon Sep 17 00:00:00 2001 From: Andrew Lorimer Date: Sat, 17 Aug 2019 14:37:21 +1000 Subject: [PATCH] fix bug where new columns were not added to database immediately --- admin.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/admin.js b/admin.js index 8fb45ff..2b82da7 100644 --- a/admin.js +++ b/admin.js @@ -211,7 +211,7 @@ function closeEdit(editbtn) { function addCol() { var ul = document.createElement("ul"); - ul.setAttribute("id", "new-category"); + ul.setAttribute("id", "new"); ul.setAttribute('draggable', 'true'); ul.addEventListener('dragstart', dragStart, false); ul.addEventListener('dragenter', dragEnter, false); @@ -229,14 +229,14 @@ function addCol() { ul.appendChild(title); var p = document.createElement("p"); - p.innerText = "new-category"; + p.innerText = "new"; title.appendChild(p); - title.insertAdjacentHTML("beforeend", "+"); + title.insertAdjacentHTML("beforeend", "+"); rmbutton = document.createElement("span"); rmbutton.setAttribute("class", "rmcol"); - rmbutton.setAttribute("id", "rmcol-new-category"); + rmbutton.setAttribute("id", "rmcol-new"); rmbutton.innerText = "-"; rmbutton.addEventListener('click', function(event){ console.log("Deleting column " + this.parentNode.parentNode); @@ -252,8 +252,9 @@ function addCol() { title.getElementsByClassName("add")[0].style.display = "flex"; title.getElementsByTagName("p")[0].style.width = "calc(100% - 90px)"; - listen(title.getElementsByClassName("add")[0]); + mainlist.push(["new"]); save(); + listen(title.getElementsByClassName("add")[0]); } function listen(li) { @@ -304,7 +305,7 @@ function addItem(caller, li) { newli.insertAdjacentHTML("beforeend", ""+nme+""); newli.insertAdjacentHTML("beforeend", rmspan[0]+columnToArray(ul).length.toString()+"-"+caller[1]+rmspan[1]); - document.getElementById(caller[1]).appendChild(newli); + document.getElementById(id).appendChild(newli); save(); listen(newli); } -- 2.47.1