-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2ef75f
commit f9c62c8
Showing
15 changed files
with
2,776 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { extractPostData, savePost } from './posts/posts.js'; | ||
|
||
const formElement = document.querySelector('form'); | ||
|
||
export async function submitFormHandler(event) { | ||
event.preventDefault(); | ||
|
||
const formData = new FormData(formElement); | ||
try { | ||
const postData = extractPostData(formData); | ||
await savePost(postData); | ||
} catch (error) { | ||
showError(error.message); | ||
} | ||
} | ||
|
||
formElement.addEventListener('submit', submitFormHandler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>More on Mocks</title> | ||
<script src="app.js" type="module" defer></script> | ||
</head> | ||
<body> | ||
<form> | ||
<div> | ||
<label for="title">Title</label> | ||
<input type="text" id="title" name="title" /> | ||
</div> | ||
<div> | ||
<label for="content">Content</label> | ||
<textarea id="content" name="content" rows="5"></textarea> | ||
</div> | ||
<button>Save Post</button> | ||
<div id="errors"></div> | ||
</form> | ||
</body> | ||
</html> |
Oops, something went wrong.