Просмотр исходного кода

Add sorting to recipes display

Lee Morgan 6 лет назад
Родитель
Сommit
9448b18898
2 измененных файлов с 2 добавлено и 1 удалено
  1. 0 1
      views/merchantSetupPage/controller.js
  2. 2 0
      views/recipesPage/recipes.js

+ 0 - 1
views/merchantSetupPage/controller.js

@@ -1,7 +1,6 @@
 let controller = {
     data: {},  //For storing all data from user to pass to backend
 
-    //Component divs
     basicInfoStrand: document.querySelector("#basicInfoStrand"),
     addIngredientsStrand: document.querySelector("#addIngredientsStrand"),
     createIngredientsStrand: document.querySelector("#createIngredientsStrand"),

+ 2 - 0
views/recipesPage/recipes.js

@@ -17,6 +17,8 @@ let recipesObj = {
         while(body.children.length > 0){
             body.removeChild(body.firstChild);
         }
+
+        merchant.recipes.sort((a, b) => (a.name > b.name)? 1 : -1);
         
         for(let recipe of merchant.recipes){
             let recipeDiv = document.createElement("div");