From 287b626d07a9d861fc6ffcc045134e5f5546a363 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 3 Jun 2022 14:02:41 -0500 Subject: [PATCH] refactoring code to make sure 2b is to spec --- js/stories.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/js/stories.js b/js/stories.js index 7e66eb1..c9a6341 100644 --- a/js/stories.js +++ b/js/stories.js @@ -57,11 +57,8 @@ function putStoriesOnPage() { */ async function getNewStoryAndSubmit(evt) { - console.debug("getNewStoryAndSubmit", evt); - // clear page then display form evt.preventDefault(); - hidePageComponents(); - $addStoryForm.show(); + // get values from form const title = $("#story-title").val(); @@ -78,9 +75,8 @@ async function getNewStoryAndSubmit(evt) { // instantiate a Story with obj and display on page const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory); console.log("resultOfAddStoryCall: ", resultOfAddStoryCall); - hidePageComponents(); - await getAndShowStoriesOnStart(); - + const newStoryMarkup = generateStoryMarkup(resultOfAddStoryCall); + $allStoriesList.prepend(newStoryMarkup); //resets form with empty values $addStoryForm.trigger("reset"); } @@ -88,6 +84,15 @@ async function getNewStoryAndSubmit(evt) { //event listener for add story form submit $addStoryForm.on("submit", getNewStoryAndSubmit); + + + + + + + + + // async function getNewStoryAndSubmit(evt) { // console.debug("getNewStoryAndSubmit", evt); // // clear page then display form