|
|
@ -52,14 +52,13 @@ function putStoriesOnPage() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** handles story form submission: takes in values from story submission
|
|
|
|
/** handles story form submission: extracts values from story submission
|
|
|
|
* form, calls addStory, generates story markup to append to page
|
|
|
|
* form, calls addStory, generates story markup to append to page
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
async function getNewStoryAndSubmit(evt) {
|
|
|
|
async function getNewStoryAndSubmit(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
evt.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get values from form
|
|
|
|
// get values from form
|
|
|
|
const title = $("#story-title").val();
|
|
|
|
const title = $("#story-title").val();
|
|
|
|
const author = $("#story-author").val();
|
|
|
|
const author = $("#story-author").val();
|
|
|
@ -77,6 +76,7 @@ async function getNewStoryAndSubmit(evt) {
|
|
|
|
console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
|
|
|
|
console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
|
|
|
|
const newStoryMarkup = generateStoryMarkup(resultOfAddStoryCall);
|
|
|
|
const newStoryMarkup = generateStoryMarkup(resultOfAddStoryCall);
|
|
|
|
$allStoriesList.prepend(newStoryMarkup);
|
|
|
|
$allStoriesList.prepend(newStoryMarkup);
|
|
|
|
|
|
|
|
|
|
|
|
//resets form with empty values
|
|
|
|
//resets form with empty values
|
|
|
|
$addStoryForm.trigger("reset");
|
|
|
|
$addStoryForm.trigger("reset");
|
|
|
|
hidePageComponents();
|
|
|
|
hidePageComponents();
|
|
|
@ -84,45 +84,4 @@ async function getNewStoryAndSubmit(evt) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//event listener for add story form submit
|
|
|
|
//event listener for add story form submit
|
|
|
|
$addStoryForm.on("submit", getNewStoryAndSubmit);
|
|
|
|
$addStoryForm.on("submit", getNewStoryAndSubmit);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
// const author = $("#story-author").val();
|
|
|
|
|
|
|
|
// const url = $("#story-url").val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // put values in an obj
|
|
|
|
|
|
|
|
// const newStory = {
|
|
|
|
|
|
|
|
// title: title,
|
|
|
|
|
|
|
|
// author: author,
|
|
|
|
|
|
|
|
// url: url
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // instantiate a Story with obj and display on page
|
|
|
|
|
|
|
|
// const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory);
|
|
|
|
|
|
|
|
// console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
|
|
|
|
|
|
|
|
// hidePageComponents();
|
|
|
|
|
|
|
|
// await getAndShowStoriesOnStart();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //resets form with empty values
|
|
|
|
|
|
|
|
// $addStoryForm.trigger("reset");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //event listener for add story form submit
|
|
|
|
|
|
|
|
// $addStoryForm.on("submit", getNewStoryAndSubmit);
|
|
|
|
|