Тёмный

How LocalStorage and Event Delegation work.  

Wes Bos
Подписаться 182 тыс.
Просмотров 31 тыс.
50% 1

Today we learn all about Local Storage in the browser and how to use something called Event Delegation to handle events on elements created in the future.
Grab all the exercises and starter files over at JavaScript30.com

Опубликовано:

 

4 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 56   
@julianstorm7722
@julianstorm7722 3 года назад
Why did I not do this series when I started with js....came here to review some concepts and found out there's fair a few things I haven't covered...Thanks for this great series....You deserve way more subs.
@WesBos
@WesBos 3 года назад
Thank you!
@frankiev1785
@frankiev1785 6 лет назад
One of my favorite videos on LocalStorage so far. Thanks Wes!
@hibritusta2642
@hibritusta2642 4 года назад
Greetings from Turkey. You have a very good expression. The subject is well understood with real life applications! Congratulations and thanks!
@alexandera6012
@alexandera6012 3 года назад
Thanks a lot, Wes! This video and the whole JS30 series are super useful and fun. Learned a lot from just watching your step-by-step building process.
@1lucas132
@1lucas132 4 года назад
Several very important concepts applied in practice ... Thanks Wes
@ArifBasri
@ArifBasri 3 года назад
timeless tutorial! thanks very much Wes!
@lukasluftlaufer1093
@lukasluftlaufer1093 3 года назад
This is so clever! Learned a lot! Thanks Wes.
@gothamfury
@gothamfury 4 года назад
Thank you for this video! I'm just getting into JavaScript and learning about LocalStorage and this has been very helpful. I like the editor you're using too. The cursive script for properties is cool.
@Ludo045
@Ludo045 2 года назад
this is helpful as a beginner ? it's a bit complicated i think... This is a changelle and i could have never ever be able to do this alone.
@shimphillip
@shimphillip 6 лет назад
Priceless Tutorial. Thanks!
@АлексейВоробьёв-щ8ф4ю
Just amazing! Thank you so much Wes!
@giadungtienichnoha9288
@giadungtienichnoha9288 4 года назад
My solution for the challenge (It can toggle between check all & clear all). // Create a button with class check-all in HTML and select it const checkAll = document.querySelector('.check-all'); // Add click event checkAll.addEventListener('click', handleCheckAll); // Function handle event function handleCheckAll(e) { const allCheck = items.every((item) => item.done === true); if (allCheck) { items.forEach((item) => (item.done = false)); } else { items.forEach((item) => (item.done = true)); } localStorage.setItem('items', JSON.stringify(items)); populateList(items, itemsList); }
@erikhendin3459
@erikhendin3459 Год назад
Thank you for sharing this! I was struggling with this, I got select all working in separate examples but not in this code context with local storage. Nice work, you helped me out.
@fespamo
@fespamo Год назад
i'm still a beginner , i realise this as i need to watch an practice this video 2 or 3 times
@avi12
@avi12 6 лет назад
12:10 Or, just wrap the input and the text in and you don't need to do that you did. I.e. ${place.text}
@nathancornwell1455
@nathancornwell1455 4 года назад
still best practice to link them together .....
@peterchen1774
@peterchen1774 6 лет назад
Really a nice video tutorial! Thanks~
@MarcelRobitaille
@MarcelRobitaille 7 лет назад
You don't need to re-render the html when you check/uncheck because you don't call preventDefault. It also might be a good idea to use el.checked rather than !items[index].done just in the off chance that this got messed up somehow.
@kissu_io
@kissu_io 6 лет назад
You need something like 'itemsList.children[0].children[0].checked' to use the checked method ? Didn't achieved to make it that way but if it's indeed using the DOM, it's pretty meh.
@talhaabbas1816
@talhaabbas1816 3 года назад
what an amazing way to teach event delegation 😂😂😂
@Mustafaismail22
@Mustafaismail22 7 лет назад
Great video, Thank you 😘
@ClevertonHeusner
@ClevertonHeusner 4 года назад
Excelent job.
@mirage4731
@mirage4731 3 года назад
I didn't understood the need of ${plates.done ? 'checked' : ''} Why we use it ??
@WesBos
@WesBos 3 года назад
If the plate has a property of done, it returns a string of “checked” which causes the HTML of the input to make it checked. Otherwise we return an empty string, which is not checked
@mirage4731
@mirage4731 3 года назад
@@WesBos thanks a lot 😁, this playlist is amazing, i loved it
@avi12
@avi12 6 лет назад
In localStorage, instead of localStorage.setItem("name", "value") - you could just: localStorage.item = "value" Also, note that there's a limit to how many strings can be stored in MBs, according to developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria
@kissu_io
@kissu_io 6 лет назад
As you're a daddy, I liked the way you explained the event delegation. :P
@polmeep9484
@polmeep9484 Год назад
Hi, how did you configure autocomplete of html tags in backticks? I'm using a VS Code but for me it's not working.
@丶-s3u
@丶-s3u 2 года назад
while input has display : none how can he detected if is checked or not ? didn't work for me so I add this code position: absolute; opacity: 0; cursor: pointer; I just wanna know how it's work for him 🤔
@trophydevice7624
@trophydevice7624 3 года назад
Has anyone tried adding a delete button? I am struggling on that one..
@akramadil7502
@akramadil7502 4 года назад
I don't clearly understand why you called"populateList" again in the end at line 60. 19:17
@julianstorm7722
@julianstorm7722 3 года назад
Without calling it again the saved keys in localstorage would only show up on submit and not on every page load.
@dentistasenciudadjuarezchi1154
done lol, i finally got a delete button to work on the list, but the only problem is that it deletes everything, instead of a single item. So i named that button delete all lmao
@burhaanhassan5498
@burhaanhassan5498 7 месяцев назад
use reduce Function and set the index !=plate.i.
@mikolwski
@mikolwski 6 лет назад
Instead of 'click' I listen to the 'change' and i think it works fine too
@wentingsong9435
@wentingsong9435 4 года назад
How do you type the taco or the poop icon there?
@francissicnarf4707
@francissicnarf4707 6 лет назад
i got same result without calling populateList when clicking checkbox 29:05
@ahherewhatsthestory
@ahherewhatsthestory 5 лет назад
Does anyone know how I can add a button to each item to delete it from the list? Any help is much appreciated.
@Bajdster
@Bajdster 2 года назад
I have a problem, 13:53 when I try to check checkbox it isn't working, checkbox doesn't responding, there is no error on console.Help
@anokhps3088
@anokhps3088 2 года назад
same problem,have you solved it out?
@TheRuky
@TheRuky 7 лет назад
AWESOME! Can you please tell me which text editor or IDE are you using? Thanks.
@julianklumpers
@julianklumpers 7 лет назад
Renato Ruškan SublimeText with the cobalt2 theme and the font is Operator Mono
@okoiful
@okoiful 6 лет назад
its actually vs code i think....
@yordangalabov2113
@yordangalabov2113 6 лет назад
Wes is using Sublime. He even has a book on it. More info here: wesbos.com/?s=sublime
@michaeldpadilla
@michaeldpadilla 6 лет назад
Wes is using VSCode with a converted Cobalt theme. That link you gave us is almost 3 years old already which is eons in the world of development. He explains this in his Syntax podcast which you all should be listening to if you haven't already! Yes, I know this video is from September 2017... He still was using VSCode then.
@yordangalabov2113
@yordangalabov2113 6 лет назад
Michael Padilla Agreed. Thanks for your reply.
@amitpurohit8816
@amitpurohit8816 3 года назад
Which editor is this??
@AhmedSamir-hx3ip
@AhmedSamir-hx3ip 5 лет назад
@ 10:25 , when i try & type something & submit it, the Loading Tapas... disapear & nothing added, then when i try to add something one more time it adds what i typed pervious, my code is just like yours thanks
@AbsarNaeem1
@AbsarNaeem1 5 лет назад
You have to place your populateList() function after the items.push() function.
@mdsagorahmed2546
@mdsagorahmed2546 4 года назад
How Can I get source file?
@WesBos
@WesBos 4 года назад
JavaSCript30.com
@bendude
@bendude 4 года назад
getting this error when i open the index-START.html file: 'Failed to load resource: the server responded with a status of 404 ()' anybody know how to fix this?
@chiragmehta84
@chiragmehta84 4 года назад
The error is caused because the background url in style.css is set to wes.io/hx9M/oh-la-la.jpg which no longer exists. Replace it with this and it'll work fine background: url('source.unsplash.com/N_Y88TWmGwA/640x426')
@NitinGoyal-tf8tz
@NitinGoyal-tf8tz Год назад
I have a better method in O(n) time complexity function addItem(){ e.preventDefault(); const text=(this.querySelector('[name=item]')).value; const newLi=document.createElement('li'); newLi.innerHTML=text; itemsList.appendChild(newLi); this.reset(); }
Далее
Understanding JavaScript Storage Events
16:55
Просмотров 3,4 тыс.
Тренд Котик по очереди
00:10
Просмотров 254 тыс.
БАГ ЕЩЕ РАБОТАЕТ?
00:26
Просмотров 247 тыс.
Обменялись песнями с POLI
00:18
Просмотров 956 тыс.
Local Storage Explained In 10 min | Javascript
10:53
Просмотров 61 тыс.
Vanilla JS Countdown Timer - #JavaScript30 29/30
21:46
5 JavaScript Concepts You HAVE TO KNOW
9:38
Просмотров 1,4 млн
Тренд Котик по очереди
00:10
Просмотров 254 тыс.