17.
Array, Set and ES2016
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
12 Comments
I like this course but, why some videos do not have subtitles? ,thx
Hey Sergio,
Good question! This Spanish subtitles feature appeared recently on SymfonyCasts, and we decided to do not translate all previous tutorials because it might be time consumed for us, but we're going to translate all our future tutorials. That's why you can miss Spanish subtitles in our past tutorials. Though some popular old courses were translated into Spanish.
What exactly tutorial do you want to have Spanish subtitles? Please, let us know and we will try to consider this request in the future.
Btw, you will be able read more about our Spanish subtitles initiative here soon, we're working on writing a new blog post about it: https://symfonycasts.com/blog
Cheers!
BTW does this app run fixture reload every time I reload the page? Because it seems like the deleted rows come back after I reload the page.
Hey Thao L.
Could you open your console and in the network tab show me what happens when you delete a row ?
Because that's not the case, fixtures aren't loaded every time, you might have an error in your delete action or the RepLogApiModel is not generating the URL's correctly
Have a nice day!
The repLog array breaks the total weigth lifted calculation, when an row is deleted. What is the best approach to remove an deleted row from the array? Should each table row keeps the array index in a data property?
Hey Jeroen V.!
Ah, you're 100% right! Nice catch! I've just pushed a code fix for this (you might see yourself pinged on an obscure GitHub commit) and we'll add a note and code block to go with it (and a note in the video). Obviously, there are a lot of ways to solve this, but here is the diff for the one I settled on: https://github.com/knpuniversity/javascript/blob/master/_tuts/array-fix-removing-replogs.diff
It's inspired by a pattern followed in ReactJS: when you create your "view" that's attached to some item in an array, you often will add a
keyto that "view", which is the index of the item in the array (so that you can handle situations exactly like this - i.e. when I delete/update that "view", I know which data to remove/update).Thanks for asking / letting us know about this! Cheers!
Somehow $row.date('key', this.repLogs.length - 1); didn't work for my browser and I had to write $row.attr('data-key', this.repLogs.length - 1); instead. Weird.
Hey Thao L.,
you have a tiny typo in there, just change $row.date() by $row.data()
Cheers!
Hey Ryan, I just went through this tutorial, and about the fix note, I don't think it works. Let's say we have 3 items: they would have "data-key"s 0, 1, 2. We then remove 1. Then we add another one. The keys should be now 0, 2, 2. What am I missing?
Hey Beo
How are you removing/adding those items? If you use the
splicefunction you should not have that problemHey MolloKhan , look at this example... It's not a 1:1 with the solution, but it should be very similar: https://jsfiddle.net/ormpLb....
Ohh now I see the problem, and the fix is easy, instead of using the array's length for determine the row's key value, you should use its ID coming from the database
"Houston: no signs of life"
Start the conversation!