working to update article form submission functionality

main
Jason 2 years ago
parent 2a330ba28d
commit 6b42e4b64c

@ -15,6 +15,7 @@ const $navUserProfile = $("#nav-user-profile");
const $navLogOut = $("#nav-logout");
const $addStoryForm = $('#add-story-form');
const $navSubmit = $('#nav-submit');
/** To make it easier for individual components to show just themselves, this
* is a useful function that hides pretty much everything on the page. After

@ -43,4 +43,6 @@ function navSubmitClick(evt) {
evt.preventDefault();
hidePageComponents();
$addStoryForm.show();
}
}
$navSubmit.on("click", navSubmitClick);

@ -50,3 +50,25 @@ function putStoriesOnPage() {
$allStoriesList.show();
}
/** handles story form submission: takes in values from story submission
* form, calls addStory, generates story markup to append to page
*/
async function getNewStoryAndSubmit(evt) {
const title = $("#story-title").val();
const author = $("#story-author").val();
const url = $("#story-url").val();
const newStory = {
title: title,
author: author,
url: url
}
const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory);
console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
putStoriesOnPage();
}

Loading…
Cancel
Save