-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.js
58 lines (43 loc) · 1.87 KB
/
form.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// phew… not a lot going on here. Please add some code!
// The following acceptance criteria should be met for the bookmark button:
console.clear();
// The data entered into the form by users should be used to create a new question
// that will be displayed as a card like the other questions.
// Listen to the form's submit event
// Prevent the default submit behavior to handle everything within JavaScript
// Read all entered data from the input fields (question, answer, tags)
// Generate all DOM element for a card with createElement()
// Insert the form's data as text into the DOM elements
// Append the card to the page, directly below the form
// Listen to the form's submit event
// 1. introduce button
const button = document.querySelector('[data-js="form__submitButton"]');
// const userQuestion = document.querySelector('[data-js="form__submitButton"]');
// 2. listen to click
// 3. prevent default behaviour
//
// auskommentiert:
// button.addEventListener("click", (event) => {
// event.preventDefault();
// });
// 4. Read all entered data from the input fields (question, answer, tags)
const form = document.querySelector('[data-js="form__formBox"]');
mehr zu 3.
// Was ist der beste/einzig mögliche Ort für prevent?
// Was genau passiert und warum ist es am falschen Ort problematisch?
form.addEventListener("submit", (event) => {
event.preventDefault();
console.log(event.target);
});
// 5. Generate all DOM element for a card with createElement()
// form.addEventListener("submit", (event) => {
// const userQuestionInput = document.querySelector(
// '[data-js="form__inputBox"]'
// );
// const userQuestion = userQuestionInput.value;
// event.preventDefault();
// console.log(event.target);
// console.log("sanity check");
// });
// 6. Insert the form's data as text into the DOM elements
// 7. Append the card to the page, directly below the form