Created
September 8, 2021 01:19
-
-
Save natafaye/93bf5119fc95f316af3baeca143e34c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Call the render function when the page loads in using the jquery ready function | |
$(function() { | |
renderDishList(); | |
}) | |
function createDish() { | |
// grab the stuff from the form and use that to create a new object | |
const dish = { | |
title: $("#title-input").val(), | |
} | |
dishes.push(dish); | |
// Rerender that part of the page | |
renderDishList(); | |
} | |
function deleteDish(dish) { | |
// make your changes to the data (the array) | |
// Rerender that part of the page | |
renderDishList(); | |
} | |
// Render the whole list of dishes | |
function renderDishList() { | |
dishes.forEach(dish => { | |
$("#dishes-container").append( renderDish(dish) ) | |
}) | |
} | |
// Return the HTML for just one dish | |
function renderDish(dish) { | |
return ` | |
<tr> | |
<td>${dish.title}</td> | |
</tr> | |
` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment