Browse Source

Bug fix: on analytics page, the buttons were double adding when it was updated.

Lee Morgan 5 năm trước cách đây
mục cha
commit
6524a0a025

+ 9 - 1
views/dashboardPage/bundle.js

@@ -3133,17 +3133,25 @@ let analytics = {
         let ingredientButtons = document.getElementById("analIngredientList");
         let recipeButtons = document.getElementById("analRecipeList");
 
+        while(ingredientButtons.children.length > 0){
+            ingredientButtons.removeChild(ingredientButtons.firstChild);
+        }
+
         for(let i = 0; i < merchant.ingredients.length; i++){
             let button = document.createElement("button");
             button.innerText = merchant.ingredients[i].ingredient.name;
             button.classList.add("choosable");
             button.onclick = ()=>{
                 this.ingredient = merchant.ingredients[i].ingredient;
-                this.displayIngredient()
+                this.displayIngredient();
             };
             ingredientButtons.appendChild(button);
         }
 
+        while(recipeButtons.children.length > 0){
+            recipeButtons.removeChild(recipeButtons.firstChild);
+        }
+
         for(let i = 0; i < merchant.recipes.length; i++){
             let button = document.createElement("button");
             button.innerText = merchant.recipes[i].name;

+ 9 - 1
views/dashboardPage/js/strands/analytics.js

@@ -37,17 +37,25 @@ let analytics = {
         let ingredientButtons = document.getElementById("analIngredientList");
         let recipeButtons = document.getElementById("analRecipeList");
 
+        while(ingredientButtons.children.length > 0){
+            ingredientButtons.removeChild(ingredientButtons.firstChild);
+        }
+
         for(let i = 0; i < merchant.ingredients.length; i++){
             let button = document.createElement("button");
             button.innerText = merchant.ingredients[i].ingredient.name;
             button.classList.add("choosable");
             button.onclick = ()=>{
                 this.ingredient = merchant.ingredients[i].ingredient;
-                this.displayIngredient()
+                this.displayIngredient();
             };
             ingredientButtons.appendChild(button);
         }
 
+        while(recipeButtons.children.length > 0){
+            recipeButtons.removeChild(recipeButtons.firstChild);
+        }
+
         for(let i = 0; i < merchant.recipes.length; i++){
             let button = document.createElement("button");
             button.innerText = merchant.recipes[i].name;