working to update article form submission functionality

main
Jason 3 years ago
parent 2a330ba28d
commit 6b42e4b64c

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

@ -44,3 +44,5 @@ function navSubmitClick(evt) {
hidePageComponents(); hidePageComponents();
$addStoryForm.show(); $addStoryForm.show();
} }
$navSubmit.on("click", navSubmitClick);

@ -50,3 +50,25 @@ function putStoriesOnPage() {
$allStoriesList.show(); $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