All language subtitles for 013 Handling Form Submission_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,200 --> 00:00:03,533 Instructor: Now we spent a lot of time 2 00:00:03,533 --> 00:00:05,100 on this state here 3 00:00:05,100 --> 00:00:07,166 and it showed a lot of alternatives 4 00:00:07,166 --> 00:00:08,666 but up to this point of course 5 00:00:08,666 --> 00:00:10,100 we're not doing too much 6 00:00:10,100 --> 00:00:11,600 with that state. 7 00:00:11,600 --> 00:00:13,866 That's what I wanna change now, though. 8 00:00:13,866 --> 00:00:15,533 Now I wanna make sure that 9 00:00:15,533 --> 00:00:17,000 this form can be submitted 10 00:00:17,000 --> 00:00:18,833 when this button is pressed 11 00:00:18,833 --> 00:00:19,200 when this button is pressed 12 00:00:19,200 --> 00:00:20,200 and that then 13 00:00:20,200 --> 00:00:22,333 we basically gather 14 00:00:22,333 --> 00:00:25,000 these different state slices here 15 00:00:25,000 --> 00:00:28,066 and combine them into one object 16 00:00:28,066 --> 00:00:29,133 which for the moment 17 00:00:29,133 --> 00:00:30,833 is then just locked to the console 18 00:00:30,833 --> 00:00:31,766 but which we can use 19 00:00:31,766 --> 00:00:34,733 for different things later 20 00:00:34,733 --> 00:00:36,866 and therefore we wanna listen 21 00:00:36,866 --> 00:00:38,833 to the form being submitted. 22 00:00:38,833 --> 00:00:41,433 Now we could add a click listener here 23 00:00:41,433 --> 00:00:44,500 to this add expense button 24 00:00:44,500 --> 00:00:45,733 but this would not be 25 00:00:45,733 --> 00:00:47,833 the best way of listening here 26 00:00:47,833 --> 00:00:48,300 the best way of listening here 27 00:00:48,300 --> 00:00:49,500 because indeed there is 28 00:00:49,500 --> 00:00:50,833 a default behavior 29 00:00:50,833 --> 00:00:52,400 built into the browser 30 00:00:52,400 --> 00:00:55,566 and built into forums on web pages. 31 00:00:55,566 --> 00:00:56,033 and built into forums on web pages. 32 00:00:56,033 --> 00:00:57,533 If a button, 33 00:00:57,533 --> 00:00:59,633 especially with type submit 34 00:00:59,633 --> 00:01:02,100 is pressed inside of a form, 35 00:01:02,100 --> 00:01:04,033 this overall form element 36 00:01:04,033 --> 00:01:05,533 will emit an event 37 00:01:05,533 --> 00:01:06,966 to which we can listen 38 00:01:06,966 --> 00:01:07,200 to which we can listen 39 00:01:07,200 --> 00:01:09,700 and that's the submit event. 40 00:01:09,700 --> 00:01:11,400 So it's on this form 41 00:01:11,400 --> 00:01:14,300 where I wanna react to on submit 42 00:01:14,300 --> 00:01:17,000 and then execute some function 43 00:01:17,000 --> 00:01:20,566 whenever this form is being submitted. 44 00:01:20,566 --> 00:01:22,566 Now that's a function I'll add here 45 00:01:22,566 --> 00:01:23,633 and I'll name it, 46 00:01:23,633 --> 00:01:27,866 submit handler like this, 47 00:01:27,866 --> 00:01:28,700 add that here, 48 00:01:28,700 --> 00:01:31,100 we just point at submit handler 49 00:01:31,100 --> 00:01:31,933 as we did it 50 00:01:31,933 --> 00:01:36,533 for all the other events as well. 51 00:01:36,533 --> 00:01:37,700 Now, the thing here 52 00:01:37,700 --> 00:01:39,566 is that I just said 53 00:01:39,566 --> 00:01:42,033 that this is a default browser behavior 54 00:01:42,033 --> 00:01:43,633 and unfortunately, 55 00:01:43,633 --> 00:01:46,433 a part of this default browser behavior 56 00:01:46,433 --> 00:01:49,866 is that if you do click this button, 57 00:01:49,866 --> 00:01:52,400 the page reloads because the browser 58 00:01:52,400 --> 00:01:55,300 actually automatically sends a request 59 00:01:55,300 --> 00:01:56,966 whenever a form is submitted 60 00:01:56,966 --> 00:01:58,100 to the server 61 00:01:58,100 --> 00:01:59,500 which is hosting this webpage. 62 00:01:59,500 --> 00:02:00,333 So in this case 63 00:02:00,333 --> 00:02:02,300 to this development server 64 00:02:02,300 --> 00:02:02,800 to this development server 65 00:02:02,800 --> 00:02:04,866 and that's not what we want here. 66 00:02:04,866 --> 00:02:06,833 Instead here, we wanna handle 67 00:02:06,833 --> 00:02:08,265 this form submission 68 00:02:08,265 --> 00:02:10,733 with Java script and manually collect 69 00:02:10,733 --> 00:02:12,433 with Java script and manually collect 70 00:02:12,433 --> 00:02:13,600 and combine the data 71 00:02:13,600 --> 00:02:15,500 and do something with it. 72 00:02:15,500 --> 00:02:17,300 Thankfully we can disable 73 00:02:17,300 --> 00:02:19,933 or prevent this default behavior 74 00:02:19,933 --> 00:02:20,833 because we again 75 00:02:20,833 --> 00:02:22,533 get an event object here, 76 00:02:22,533 --> 00:02:24,166 automatically just as 77 00:02:24,166 --> 00:02:26,466 for the change events 78 00:02:26,466 --> 00:02:26,700 for the change events 79 00:02:26,700 --> 00:02:28,600 and on this object, 80 00:02:28,600 --> 00:02:33,466 we can call a prevent default method. 81 00:02:33,466 --> 00:02:35,533 This is built into JavaScript 82 00:02:35,533 --> 00:02:37,066 nothing reacts specific 83 00:02:37,066 --> 00:02:39,933 this default JavaScript behavior. 84 00:02:39,933 --> 00:02:41,466 We can prevent the default 85 00:02:41,466 --> 00:02:44,233 of this request being sent 86 00:02:44,233 --> 00:02:44,533 of this request being sent 87 00:02:44,533 --> 00:02:46,866 and since that request is not sent 88 00:02:46,866 --> 00:02:48,900 the page will now also not reload 89 00:02:48,900 --> 00:02:49,800 because we stay 90 00:02:49,800 --> 00:02:51,266 on the currently loaded page 91 00:02:51,266 --> 00:02:53,800 without sending any request anywhere 92 00:02:53,800 --> 00:02:55,933 and we can continue handling this 93 00:02:55,933 --> 00:02:59,100 with Java script. 94 00:02:59,100 --> 00:03:00,000 So they offer now 95 00:03:00,000 --> 00:03:02,733 we can create our 96 00:03:02,733 --> 00:03:05,933 let's say expense data object here 97 00:03:05,933 --> 00:03:06,133 let's say expense data object here 98 00:03:06,133 --> 00:03:07,233 and now we'll combine 99 00:03:07,233 --> 00:03:09,433 all that entered data. 100 00:03:09,433 --> 00:03:11,000 Of course, if you used this 101 00:03:11,000 --> 00:03:12,233 one state instead of 102 00:03:12,233 --> 00:03:13,600 free States approach 103 00:03:13,600 --> 00:03:16,700 you already have such a combined object 104 00:03:16,700 --> 00:03:18,000 but I don't have that here. 105 00:03:18,000 --> 00:03:19,166 So I will now create it 106 00:03:19,166 --> 00:03:21,066 once the form is submitted 107 00:03:21,066 --> 00:03:23,666 and simply add a title here 108 00:03:23,666 --> 00:03:24,233 and simply add a title here 109 00:03:24,233 --> 00:03:26,333 and set this to the value stored 110 00:03:26,333 --> 00:03:28,666 in the entered title state, 111 00:03:28,666 --> 00:03:30,633 add an amount property 112 00:03:30,633 --> 00:03:33,866 and set this to entered amount 113 00:03:33,866 --> 00:03:34,133 and set this to entered amount 114 00:03:34,133 --> 00:03:36,100 and a date property 115 00:03:36,100 --> 00:03:39,166 and actually set this to a new date, 116 00:03:39,166 --> 00:03:40,500 constructing a new date 117 00:03:40,500 --> 00:03:43,200 with the built in date constructor 118 00:03:43,200 --> 00:03:43,366 with the built in date constructor 119 00:03:43,366 --> 00:03:44,433 to which then in turn 120 00:03:44,433 --> 00:03:46,366 I passed the entered date 121 00:03:46,366 --> 00:03:48,300 which will parse that date string 122 00:03:48,300 --> 00:03:51,633 and converted into a date object. 123 00:03:51,633 --> 00:03:53,433 Now these property names here, 124 00:03:53,433 --> 00:03:56,133 title, amount and date are up to you 125 00:03:56,133 --> 00:03:58,033 because this is your object. 126 00:03:58,033 --> 00:03:58,433 because this is your object. 127 00:03:58,433 --> 00:03:59,433 This year, of course 128 00:03:59,433 --> 00:04:01,433 entered title, entered amount 129 00:04:01,433 --> 00:04:02,700 and entered date 130 00:04:02,700 --> 00:04:05,533 points at these state variables 131 00:04:05,533 --> 00:04:07,300 so to say. 132 00:04:07,300 --> 00:04:09,600 If you used the combined approach 133 00:04:09,600 --> 00:04:10,633 you also might wanna 134 00:04:10,633 --> 00:04:12,500 remap the property names 135 00:04:12,500 --> 00:04:13,600 because later in the app, 136 00:04:13,600 --> 00:04:15,166 I will rely on having 137 00:04:15,166 --> 00:04:18,700 a title amount and date property name. 138 00:04:18,700 --> 00:04:19,065 a title amount and date property name. 139 00:04:19,065 --> 00:04:19,933 So make sure that 140 00:04:19,933 --> 00:04:21,266 these property names exist 141 00:04:21,266 --> 00:04:23,733 and hold the correct value 142 00:04:23,733 --> 00:04:24,900 and then for the moment 143 00:04:24,900 --> 00:04:29,933 I will just console log expense data 144 00:04:29,933 --> 00:04:32,366 so that we can see that. 145 00:04:32,366 --> 00:04:34,400 Now, if we reload this 146 00:04:34,400 --> 00:04:37,500 and enter test and 1299 147 00:04:37,500 --> 00:04:39,366 and then pick some date here 148 00:04:39,366 --> 00:04:41,733 if I click add expense, 149 00:04:41,733 --> 00:04:42,800 that's looking good. 150 00:04:42,800 --> 00:04:43,766 We've got this object, 151 00:04:43,766 --> 00:04:46,633 which has all that data stored. 152 00:04:46,633 --> 00:04:47,700 which has all that data stored. 153 00:04:47,700 --> 00:04:49,300 So this now all the works 154 00:04:49,300 --> 00:04:50,600 and we are reacting 155 00:04:50,600 --> 00:04:52,766 to the form submission. 156 00:04:52,766 --> 00:04:55,933 Now, I also wanna clear the inputs 157 00:04:55,933 --> 00:04:57,966 to delete the entered values 158 00:04:57,966 --> 00:05:00,266 when that form is submitted. 10394

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.