From 4ed3b14188aaf42d1780b3881fa4f36b5af31af8 Mon Sep 17 00:00:00 2001 From: Alex Peter Date: Mon, 1 Apr 2019 10:11:42 -0500 Subject: [PATCH 1/4] added js file, added links to jquery, script.js --- index.html | 6 +++++- script.js | 0 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 script.js diff --git a/index.html b/index.html index fa08eb38..05a83465 100644 --- a/index.html +++ b/index.html @@ -66,6 +66,10 @@

Shopping List

- + + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 00000000..e69de29b From 360cf3a52f4c003a95d4cde2861d1b891476db53 Mon Sep 17 00:00:00 2001 From: Alex Peter Date: Mon, 1 Apr 2019 10:27:02 -0500 Subject: [PATCH 2/4] updated notes in js file --- script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/script.js b/script.js index e69de29b..4d9387c3 100644 --- a/script.js +++ b/script.js @@ -0,0 +1,14 @@ +//FORM: +//Create code that stops form from being submitted. Also +//should code so that it adds a child list to the li items +$("form").submit(function( event ) { + event.preventDefault(); +} + + +//SHOPPING-ITEM-TOGGLE: +//create functionality that, when pressed, crosses or +//uncrosses the selected item from the list + +//SHOPPING-ITEM-DELETE: +//create functionality that deletes this \ No newline at end of file From ae064116a55d7cd41b445c012950c800739a8c29 Mon Sep 17 00:00:00 2001 From: Alex Peter Date: Mon, 1 Apr 2019 12:52:29 -0500 Subject: [PATCH 3/4] final --- index.html | 4 ++-- script.js | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 05a83465..ca7494b8 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,7 @@

Shopping List

- +
@@ -72,4 +72,4 @@

Shopping List

crossorigin="anonymous"> - \ No newline at end of file + diff --git a/script.js b/script.js index 4d9387c3..f40a0b8d 100644 --- a/script.js +++ b/script.js @@ -1,14 +1,48 @@ //FORM: //Create code that stops form from being submitted. Also //should code so that it adds a child list to the li items -$("form").submit(function( event ) { +$("form").submit(function(event) { event.preventDefault(); -} + var itemValue = $("#shopping-list-entry").val(); + console.log(itemValue); + if (itemValue.length === 0) { + alert('Cannot be blank!') + } else { + let newRow = $(` +
  • + ${itemValue} +
    + + +
    +
  • `); + $(".shopping-list").append(newRow) + } + //add new list item to ul, add shopping item text to span, + //add buttons - delete and check - and add labels to buttons +}); //SHOPPING-ITEM-TOGGLE: //create functionality that, when pressed, crosses or //uncrosses the selected item from the list +// $(".shopping-item-toggle").click(function(event) { +$(document).on("click", ".shopping-item-toggle", function(event) { + event.preventDefault(); + console.log($(this)); + $(this).parent().parent().find(".shopping-item").toggleClass("shopping-item__checked"); + //$(this).addClass(".shopping-item__checked"); +}) + //SHOPPING-ITEM-DELETE: -//create functionality that deletes this \ No newline at end of file +//create functionality that deletes this + +$(document).on("click", ".shopping-item-delete", function(event) { + event.preventDefault(); + $(this).parent().parent().remove(); +}) From a7bf019f75b09d2aa94b84a1d0fb660ade638ea4 Mon Sep 17 00:00:00 2001 From: Alex Peter Date: Mon, 1 Apr 2019 12:53:34 -0500 Subject: [PATCH 4/4] forgot to restore something --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index ca7494b8..1cbc451b 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,7 @@

    Shopping List

    - +