|
|
@ -57,11 +57,8 @@ function putStoriesOnPage() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
async function getNewStoryAndSubmit(evt) {
|
|
|
|
async function getNewStoryAndSubmit(evt) {
|
|
|
|
console.debug("getNewStoryAndSubmit", evt);
|
|
|
|
|
|
|
|
// clear page then display form
|
|
|
|
|
|
|
|
evt.preventDefault();
|
|
|
|
evt.preventDefault();
|
|
|
|
hidePageComponents();
|
|
|
|
|
|
|
|
$addStoryForm.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get values from form
|
|
|
|
// get values from form
|
|
|
|
const title = $("#story-title").val();
|
|
|
|
const title = $("#story-title").val();
|
|
|
@ -78,9 +75,8 @@ async function getNewStoryAndSubmit(evt) {
|
|
|
|
// instantiate a Story with obj and display on page
|
|
|
|
// instantiate a Story with obj and display on page
|
|
|
|
const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory);
|
|
|
|
const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory);
|
|
|
|
console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
|
|
|
|
console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
|
|
|
|
hidePageComponents();
|
|
|
|
const newStoryMarkup = generateStoryMarkup(resultOfAddStoryCall);
|
|
|
|
await getAndShowStoriesOnStart();
|
|
|
|
$allStoriesList.prepend(newStoryMarkup);
|
|
|
|
|
|
|
|
|
|
|
|
//resets form with empty values
|
|
|
|
//resets form with empty values
|
|
|
|
$addStoryForm.trigger("reset");
|
|
|
|
$addStoryForm.trigger("reset");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -88,6 +84,15 @@ 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) {
|
|
|
|
// async function getNewStoryAndSubmit(evt) {
|
|
|
|
// console.debug("getNewStoryAndSubmit", evt);
|
|
|
|
// console.debug("getNewStoryAndSubmit", evt);
|
|
|
|
// // clear page then display form
|
|
|
|
// // clear page then display form
|
|
|
|