1 00:00:01,770 --> 00:00:06,330 Welcome back, ladies and gentlemen, today, what we are going to do, we're going to work on the controller 2 00:00:06,330 --> 00:00:13,580 for the car now for that thing, we first need to use this ADD event listener. 3 00:00:13,590 --> 00:00:16,320 So we're going to add one more else if here. 4 00:00:17,370 --> 00:00:22,560 And we're going to target using either Target matches, if it's the main control left by, it's clicked. 5 00:00:24,000 --> 00:00:25,110 OK, let's do that. 6 00:00:25,110 --> 00:00:29,610 And from there, we're going to call the we're going to call actually the controller. 7 00:00:29,790 --> 00:00:33,990 Now, here we can see increase or decrease ticket number in comma. 8 00:00:34,110 --> 00:00:36,810 We can say add tickets. 9 00:00:42,200 --> 00:00:52,430 Tickets to Cark no good show, what we need here is again else actually let's call this one the entire 10 00:00:52,430 --> 00:00:52,670 one. 11 00:00:52,910 --> 00:00:56,890 So I'm just going to copy it just to be quicker, close this one. 12 00:00:57,440 --> 00:01:02,450 But here, instead of Hedo Target matches, I want ladies and gentlemen, to go back your movie. 13 00:01:03,590 --> 00:01:05,650 Let's click one over here. 14 00:01:05,660 --> 00:01:10,790 I just want to target this button when it's this button actually clicked. 15 00:01:10,790 --> 00:01:14,690 And what's happening here, I can't find it here. 16 00:01:14,690 --> 00:01:16,460 It's main content left by. 17 00:01:16,490 --> 00:01:19,970 So I need to target actually D class here. 18 00:01:20,150 --> 00:01:26,570 So I'm going to see main content left by and also all of its children. 19 00:01:26,750 --> 00:01:27,070 Good. 20 00:01:27,260 --> 00:01:28,120 Now I'm good to go. 21 00:01:28,130 --> 00:01:29,540 Let's alert. 22 00:01:32,660 --> 00:01:39,470 And the car clicked just to check if it's working or not because it will give us a lot of trouble if 23 00:01:39,470 --> 00:01:40,520 it's not working here it is. 24 00:01:40,520 --> 00:01:41,180 It is working. 25 00:01:41,390 --> 00:01:42,950 So we successfully target that one. 26 00:01:43,400 --> 00:01:48,170 And if we click outside here will be on the text on the icon, it will still work. 27 00:01:48,230 --> 00:01:48,790 Not good. 28 00:01:49,040 --> 00:01:50,990 So from here I'm going to call the car controller 29 00:01:53,510 --> 00:01:56,780 and here this controller we have and create it right now. 30 00:01:56,780 --> 00:02:01,430 I'm just going to copy it here and we need to go back to where the car control. 31 00:02:01,450 --> 00:02:07,670 So last time, I believe, delete the things that we have window that we can do that we don't need it. 32 00:02:08,210 --> 00:02:15,680 No, I'm going to say const here const and I'm going to pass this card controller. 33 00:02:15,680 --> 00:02:22,670 But remember, we need an equal sign here and we need this arrow function now inside. 34 00:02:22,670 --> 00:02:26,930 First we need to create a new card. 35 00:02:26,930 --> 00:02:30,590 But first let's first check that code is exists or not. 36 00:02:30,710 --> 00:02:37,550 So I'm going to say if it's different than the other card means, if it's not there, if it's not in 37 00:02:37,550 --> 00:02:38,870 the data right. 38 00:02:39,380 --> 00:02:43,760 Then we can just create a DataDot card equal to the new card. 39 00:02:43,770 --> 00:02:47,480 So see how this cool it's we don't have to use that brackets. 40 00:02:47,480 --> 00:02:48,470 It's in one line. 41 00:02:48,470 --> 00:02:52,760 So it means that if there is no data card here, if it's nothing in the in the cart. 42 00:02:54,050 --> 00:02:54,460 Right. 43 00:02:55,160 --> 00:02:57,710 So we can create that one straight away. 44 00:02:58,190 --> 00:02:58,630 Nice. 45 00:02:58,640 --> 00:03:01,850 So we created that new object now. 46 00:03:03,980 --> 00:03:05,960 And movie details 47 00:03:11,090 --> 00:03:16,760 and also make sure that you have added this important part of you on top, right. 48 00:03:17,330 --> 00:03:18,350 Just copy this line. 49 00:03:18,350 --> 00:03:30,790 Here is part of our view in here, just below that, and also make sure that you have the Cartmell. 50 00:03:31,220 --> 00:03:31,540 Good. 51 00:03:34,370 --> 00:03:41,210 OK, now add movie details, so here I'm going to create a constant called movie item, and in that 52 00:03:41,210 --> 00:03:47,860 movie I'm going to see data that cart that at item good here. 53 00:03:47,870 --> 00:03:49,740 What I'm going to do, I'm going to see data. 54 00:03:50,140 --> 00:03:54,560 Now, this item is actually from the Karkh controller. 55 00:03:55,040 --> 00:03:55,430 Right. 56 00:03:55,670 --> 00:03:57,320 Let me just copy what we have here. 57 00:03:57,350 --> 00:03:59,870 OK, we adding the number, the title, The Price. 58 00:04:01,830 --> 00:04:09,840 And so I'm just going to base it here, but we don't have it to grab from anywhere, but we do have 59 00:04:09,840 --> 00:04:14,610 access to them through the movie object right in here. 60 00:04:14,620 --> 00:04:22,470 I'm going to see no tickets, good data, that movie, that title. 61 00:04:22,680 --> 00:04:24,120 And we don't have a price now. 62 00:04:24,120 --> 00:04:28,110 We don't have a price in our model right now. 63 00:04:28,110 --> 00:04:29,520 We're actually movie model. 64 00:04:31,650 --> 00:04:39,330 And what we can do, we can pass the number here or we can just go back to a movie that is in added 65 00:04:39,330 --> 00:04:40,020 somewhere here. 66 00:04:40,020 --> 00:04:44,160 I'm just going to have this that price and I'm going to fix this. 67 00:04:45,210 --> 00:04:47,960 Sorry, I'm going to fix this one to ten dollars. 68 00:04:48,900 --> 00:04:49,780 That's pretty much it. 69 00:04:50,020 --> 00:04:53,670 Now I do have the Access DataDot movie. 70 00:04:53,940 --> 00:04:55,050 That price now. 71 00:04:55,560 --> 00:04:55,910 Cool. 72 00:04:56,520 --> 00:04:57,970 So what is happening here? 73 00:04:57,990 --> 00:05:00,780 Let's add a couple of more things and we're going to test this out. 74 00:05:01,050 --> 00:05:03,810 So no, here we need to display 75 00:05:06,420 --> 00:05:10,100 this lady movie item. 76 00:05:10,740 --> 00:05:11,950 And how are we going to do that? 77 00:05:12,060 --> 00:05:18,450 We're going to take care of you so we have the access of the card you and display movie item. 78 00:05:18,630 --> 00:05:26,780 And inside we are passing this item where we stored everything here that we had it cool less Bahige 79 00:05:26,790 --> 00:05:30,400 to create to display the card number. 80 00:05:34,020 --> 00:05:42,810 Now this will say consed card number DataDot card that show list. 81 00:05:45,960 --> 00:05:50,190 OK, why the show to me, I have no idea, so they can't show this. 82 00:05:50,340 --> 00:05:51,530 That was in the car. 83 00:05:51,840 --> 00:05:54,170 I'm just going to show it to you in here. 84 00:05:54,860 --> 00:06:01,050 We can do we can just so it's returning the entire array, but we can just return the length of this 85 00:06:01,050 --> 00:06:01,340 array. 86 00:06:01,350 --> 00:06:01,630 Right. 87 00:06:01,660 --> 00:06:04,890 And I can do it then, but I'm going to do that in alikes. 88 00:06:05,250 --> 00:06:07,680 So I'm just going to trying to show you how we can do this. 89 00:06:07,830 --> 00:06:09,270 So I'm going to, you know, like, smile. 90 00:06:09,300 --> 00:06:10,800 I'm going to do it in the car. 91 00:06:11,040 --> 00:06:17,320 But here so I have stored the entire ride back here and this is look like ugly a bit. 92 00:06:17,520 --> 00:06:28,170 Now here I'm going to use the car, view that display car number, and I'm going to pass that card number 93 00:06:28,200 --> 00:06:31,660 that we grab from the saved, actually. 94 00:06:31,680 --> 00:06:34,260 So this array and I can grab the length from here. 95 00:06:34,320 --> 00:06:35,850 Same it's pretty much same. 96 00:06:35,850 --> 00:06:40,340 But I could have done it here, but I would do this in the next lecture. 97 00:06:40,390 --> 00:06:43,210 OK, so that is pretty much it. 98 00:06:43,440 --> 00:06:44,900 So let's test this out. 99 00:06:46,350 --> 00:06:48,180 I'm just going to go here. 100 00:06:48,180 --> 00:06:54,900 I'm going to refresh and I'm going to buy the ticket and nothing is happening. 101 00:06:55,500 --> 00:06:57,890 OK, so we do have some problem probably. 102 00:06:58,170 --> 00:07:05,130 Now, how are we going to test if we do have a problem, let's first test if these actually cancel the 103 00:07:05,130 --> 00:07:08,370 log movie items working as we are, we have planned. 104 00:07:08,550 --> 00:07:08,870 Right. 105 00:07:09,000 --> 00:07:16,680 So if we're getting some data and actually we don't have anything movie, click here, add it, let's 106 00:07:16,680 --> 00:07:17,700 inspect it. 107 00:07:17,940 --> 00:07:20,070 And I want to see an object here. 108 00:07:22,740 --> 00:07:25,220 And actually that object is not there. 109 00:07:27,150 --> 00:07:30,810 So probably we do have some problem over here. 110 00:07:30,810 --> 00:07:33,870 Data that movie, the price data, the movie, the number. 111 00:07:34,140 --> 00:07:38,430 OK, instead of movie, I have moved. 112 00:07:38,440 --> 00:07:38,700 Right. 113 00:07:38,700 --> 00:07:41,250 So you probably have done this one before me. 114 00:07:41,460 --> 00:07:42,890 So know this is it is. 115 00:07:42,960 --> 00:07:44,880 I do have this one and should work now. 116 00:07:45,370 --> 00:07:45,690 Oops. 117 00:07:45,690 --> 00:07:46,710 Again, it's not working. 118 00:07:46,710 --> 00:07:54,390 It's zero now so I've tested it until here it is working now I can remove this and let's see if this 119 00:07:54,390 --> 00:07:58,980 display movie that was located in this car is actually being called. 120 00:07:59,100 --> 00:08:01,740 So I'm going to call the log item. 121 00:08:01,740 --> 00:08:05,970 And actually this item that we are passing here, it was the same that we just can't plug it. 122 00:08:05,970 --> 00:08:07,020 See, it's this one. 123 00:08:07,260 --> 00:08:09,240 So I should be able to see the same result. 124 00:08:09,240 --> 00:08:13,730 So if I click again, buy tickets, OK, it's working. 125 00:08:13,770 --> 00:08:15,320 So something strange is happening. 126 00:08:15,840 --> 00:08:19,260 No, I was thinking it's not calling the function, so it's working there. 127 00:08:19,260 --> 00:08:21,210 So we must have some problem here. 128 00:08:21,600 --> 00:08:22,950 So let's go. 129 00:08:23,370 --> 00:08:23,970 It is. 130 00:08:24,120 --> 00:08:31,230 So I'm passing the item and I'm trying to get the title from the movie, which I haven't access to the 131 00:08:31,230 --> 00:08:31,740 movie here. 132 00:08:31,830 --> 00:08:35,520 I have access to the item that I'm passing that was movie on top here. 133 00:08:35,910 --> 00:08:38,070 Then we can just simply do it. 134 00:08:38,430 --> 00:08:45,760 OK, so changes to item the title, let's add it in. 135 00:08:45,780 --> 00:08:46,230 Here it is. 136 00:08:46,230 --> 00:08:49,260 We do have it, but so we have the title. 137 00:08:49,260 --> 00:08:51,390 We have this the price. 138 00:08:52,770 --> 00:09:00,540 We don't have this number of items right in probably you know, this it missing these quotes here. 139 00:09:00,720 --> 00:09:03,480 I'm going to save it and he's going to give me this. 140 00:09:03,480 --> 00:09:09,540 So if it gives you this, as I told you, it's an error because we trying to load something that doesn't 141 00:09:09,540 --> 00:09:09,930 exist. 142 00:09:10,290 --> 00:09:12,810 I'm just going to increase the number of tickets I'm going to buy. 143 00:09:12,990 --> 00:09:16,470 And I want to see here that I do have two and twenty. 144 00:09:16,560 --> 00:09:16,890 Good. 145 00:09:17,130 --> 00:09:18,900 Now that is working. 146 00:09:18,900 --> 00:09:26,880 So next thing is we need to add even listner here when we click on this actually delete button and that 147 00:09:26,880 --> 00:09:34,590 I need to show you, it's there in a target in our list delete actually in this one in the button. 148 00:09:34,740 --> 00:09:35,540 So we're going to target. 149 00:09:35,550 --> 00:09:39,420 So this is not wrapped in a div, but we're going to target the button here. 150 00:09:39,450 --> 00:09:45,890 OK, but before that, we need to use this target list to grab this data, delete it. 151 00:09:45,900 --> 00:09:49,530 Remember, we're passing here so we will be able to delete it. 152 00:09:49,530 --> 00:09:50,000 Nice. 153 00:09:50,640 --> 00:09:56,310 So let's go back here and here, add to another event. 154 00:09:56,640 --> 00:09:59,160 So increase or decrease ticket number here. 155 00:09:59,160 --> 00:10:04,080 I will say delete an update card. 156 00:10:04,320 --> 00:10:05,310 OK, cool. 157 00:10:05,580 --> 00:10:12,780 I'm going to add event listeners at the end, delete and update the card. 158 00:10:13,050 --> 00:10:13,410 Good. 159 00:10:13,650 --> 00:10:16,110 So here we need to specify something. 160 00:10:16,590 --> 00:10:22,740 The first thing that we need to specify is seeing the class names, dot card container. 161 00:10:22,980 --> 00:10:25,470 We're going to use the same container that we were working on. 162 00:10:26,070 --> 00:10:33,360 So car container, that air event listener here and it will be on click here. 163 00:10:33,360 --> 00:10:36,510 I'm going to pass the E the event. 164 00:10:36,510 --> 00:10:36,900 Right. 165 00:10:37,230 --> 00:10:39,450 So I want to use Target. 166 00:10:39,630 --> 00:10:44,010 So how I'm going to grab the the data set. 167 00:10:44,270 --> 00:10:52,400 Dana said the lead item, so I need to actually find to get this class and find the closest, right, 168 00:10:52,550 --> 00:10:53,630 so we have done this. 169 00:10:53,660 --> 00:10:59,980 So I'm going to see if it can't study here and I'm going to see the target because I've the event here. 170 00:11:00,080 --> 00:11:06,190 So I have the exit and start closest in here. 171 00:11:06,200 --> 00:11:13,580 I'm going to pass the function, the class that I've just copied now how we are, but we just find the 172 00:11:13,580 --> 00:11:14,060 closest. 173 00:11:14,060 --> 00:11:21,470 But we need to grab this dataset and the keyword is data set. 174 00:11:22,190 --> 00:11:30,620 And then the name the lead I.D. cuz let's cancel it, log and see if we are grabbing the correct idea 175 00:11:30,620 --> 00:11:31,040 or not. 176 00:11:32,810 --> 00:11:33,860 Again, something wrong. 177 00:11:33,870 --> 00:11:35,200 Don't worry about this messages. 178 00:11:36,200 --> 00:11:36,620 Come on. 179 00:11:39,240 --> 00:11:41,340 So go back to movie 180 00:11:43,650 --> 00:11:46,230 and edit here. 181 00:11:49,600 --> 00:11:57,470 So when I click the minus actually delete element, I will be able to see the here is that's the idea. 182 00:11:57,730 --> 00:12:03,820 So if I click on Right, click inspect it and I will see that is here the same one. 183 00:12:03,880 --> 00:12:04,230 Right. 184 00:12:04,540 --> 00:12:06,730 Key JDB at the end. 185 00:12:06,880 --> 00:12:09,300 Keystart start with key JBI at the end. 186 00:12:09,310 --> 00:12:09,790 That's the one. 187 00:12:10,000 --> 00:12:19,420 OK, now what we can do here is I want to target this class here now from the bottom right. 188 00:12:19,870 --> 00:12:21,960 And I will use the matches here again. 189 00:12:21,970 --> 00:12:30,640 So if either target that matches here, I'm going to pass as a first argument the class then with the 190 00:12:30,640 --> 00:12:35,710 comma again, DOT and the Asterix to grab all the kids there. 191 00:12:35,860 --> 00:12:38,380 So here we are going to do two to three things. 192 00:12:38,380 --> 00:12:46,780 First, we need to delete the item from store, right. 193 00:12:46,780 --> 00:12:47,890 From the data, actually. 194 00:12:48,220 --> 00:13:00,220 So what we can do data that car, not delete delete item and we're going to pass the idea that we have. 195 00:13:00,400 --> 00:13:00,730 Right. 196 00:13:00,760 --> 00:13:03,490 This is actually from the card delete item. 197 00:13:03,600 --> 00:13:03,960 Right. 198 00:13:04,180 --> 00:13:05,710 So make sure you do have the same spelling. 199 00:13:06,460 --> 00:13:12,040 Now, the second thing that we want to do is actually to delete the same item from the UI. 200 00:13:12,250 --> 00:13:15,280 And in the UI we do have the same method. 201 00:13:16,120 --> 00:13:17,120 Delete the item. 202 00:13:17,140 --> 00:13:21,340 Cuz now can't you delete. 203 00:13:21,640 --> 00:13:26,140 Actually I have it pasted there in here again we are just passing the ID. 204 00:13:26,140 --> 00:13:30,070 So what it will do, it will go here, find the parent then delete it. 205 00:13:30,070 --> 00:13:30,430 Right. 206 00:13:30,850 --> 00:13:33,640 And we're still targeting that one there next. 207 00:13:35,020 --> 00:13:39,690 Now I just want to update the card number, remember the card number on top. 208 00:13:39,700 --> 00:13:40,980 So I just want to updated that. 209 00:13:41,170 --> 00:13:43,330 So update the card number. 210 00:13:44,770 --> 00:13:45,310 Nice. 211 00:13:47,290 --> 00:13:48,160 How are we going to do this? 212 00:13:48,490 --> 00:13:52,660 So again, I'm going to say cost card number. 213 00:13:54,280 --> 00:13:55,210 Actually, let's grab. 214 00:14:00,180 --> 00:14:08,550 And put it there so they know that card number and after that, we just calling the same one, save 215 00:14:08,550 --> 00:14:14,140 it, ignore this error, just go back here at movie. 216 00:14:14,430 --> 00:14:16,110 Actually, I'm just going to close this one. 217 00:14:16,290 --> 00:14:24,080 I'm going to add to from this one, I'm going to add one ticket and one ticket from a scary movie. 218 00:14:24,770 --> 00:14:25,950 I should have three now. 219 00:14:26,160 --> 00:14:27,660 OK, here it is. 220 00:14:27,720 --> 00:14:33,350 So if I click on this one, I should expect to be deleted from here, also from the car and also from 221 00:14:33,360 --> 00:14:34,230 updated this one. 222 00:14:35,610 --> 00:14:36,230 There you go. 223 00:14:36,360 --> 00:14:37,020 There you go. 224 00:14:37,050 --> 00:14:46,380 So if we go inspect here and see data that car, because in data we do have search, movie and car. 225 00:14:46,620 --> 00:14:52,620 Now I'm just going to say DataDot car and inside I should be able to see only one here it is only one. 226 00:14:52,620 --> 00:14:53,640 And that's this one. 227 00:14:53,880 --> 00:14:59,010 The Lego Movie right in the title area is a Lego Movie. 228 00:14:59,400 --> 00:15:00,300 Enterprise is. 229 00:15:00,430 --> 00:15:01,610 No it's then. 230 00:15:01,770 --> 00:15:02,350 Good, good. 231 00:15:02,770 --> 00:15:05,600 Also I really, really like the way it's working. 232 00:15:06,030 --> 00:15:06,580 Nice. 233 00:15:06,580 --> 00:15:11,630 So there is a different price because we're multiplying here right now. 234 00:15:11,760 --> 00:15:13,260 That's pretty much it now. 235 00:15:13,260 --> 00:15:18,120 We need to work on something else and we are done, I promise. 236 00:15:18,330 --> 00:15:22,970 So we need to actually update the ticket number as well. 237 00:15:23,190 --> 00:15:25,230 So let's do this now. 238 00:15:25,230 --> 00:15:36,030 Here it will be say else if e dot target that matches in for this, we need to create a couple of more 239 00:15:37,320 --> 00:15:38,490 functions in. 240 00:15:38,490 --> 00:15:40,310 You know, you will see what I'm trying to say. 241 00:15:40,350 --> 00:15:46,950 So here I'm going to see that target in our list. 242 00:15:48,940 --> 00:15:55,740 No, so actually, the class that we just put it here, this one target in our list, no. 243 00:15:55,750 --> 00:15:59,460 So when something's changed here, I want to update it as well. 244 00:15:59,860 --> 00:16:01,960 The ticket numbers. 245 00:16:02,260 --> 00:16:05,290 OK, so that will do its job. 246 00:16:05,710 --> 00:16:17,310 And I will say consed new ticket number and that will be equal to e dot target dot value. 247 00:16:17,500 --> 00:16:17,860 Right. 248 00:16:18,070 --> 00:16:23,930 So I just want to grab this input value, but this input value will give me a street. 249 00:16:24,010 --> 00:16:26,190 So how I can do it, I can just pass it. 250 00:16:26,220 --> 00:16:28,930 So I'm just going to, just going to cut this part here. 251 00:16:29,950 --> 00:16:32,320 So I'm going to cut it and I'm going to say pass. 252 00:16:34,560 --> 00:16:40,620 In and inside, I'm going to pass the target that value now I will have a number stored here, NISP, 253 00:16:40,890 --> 00:16:42,000 that will be the number 254 00:16:44,790 --> 00:16:51,520 movie and go back here and it had a there and that will be this number. 255 00:16:51,540 --> 00:16:53,030 So when we go up and down, right. 256 00:16:53,850 --> 00:17:02,580 So every time that is fired up, it will go here, it will match it and the number of the ticket will 257 00:17:02,610 --> 00:17:03,330 be stored here. 258 00:17:03,690 --> 00:17:12,780 So what I want here to say, if you take ticket number is greater than one, then what I want to do 259 00:17:12,930 --> 00:17:22,830 is I'm going to say data, that card, that update, update, update number, movies. 260 00:17:24,360 --> 00:17:25,500 And here I'm going to pass. 261 00:17:26,160 --> 00:17:31,110 So we need to go back to the card and we need to grab this one. 262 00:17:31,110 --> 00:17:31,390 Right. 263 00:17:33,030 --> 00:17:34,440 Did I spelled correctly good. 264 00:17:34,440 --> 00:17:34,810 Correct. 265 00:17:35,010 --> 00:17:39,050 So I need to pass the I.D. here that we grab it from top. 266 00:17:40,380 --> 00:17:41,850 What else I need to pass in here? 267 00:17:42,360 --> 00:17:44,510 The new ticket number. 268 00:17:46,200 --> 00:17:46,800 Nice. 269 00:17:47,280 --> 00:17:48,660 That was to update. 270 00:17:48,660 --> 00:17:51,500 Now update that number from car. 271 00:17:52,230 --> 00:17:53,640 We need to create an additional one. 272 00:17:53,880 --> 00:18:00,990 Update the ticket number from card in here. 273 00:18:01,260 --> 00:18:06,030 We need to create actually two two new functions. 274 00:18:06,030 --> 00:18:10,710 The first function will be data that I'm just going to write it here. 275 00:18:10,800 --> 00:18:14,430 And after that I'm going to go in the movie model and I'm going to update it. 276 00:18:17,620 --> 00:18:21,030 Actually, it will be update from car. 277 00:18:21,100 --> 00:18:27,460 So what I have here, I just want to update even the movie, because in the movie we do have the number 278 00:18:27,460 --> 00:18:29,910 of tickets I want to update as well over there. 279 00:18:30,160 --> 00:18:33,690 And that is why I needed this function. 280 00:18:33,970 --> 00:18:41,820 So seeing from her from card, because it's actually in the card here right now, new ticket number. 281 00:18:41,830 --> 00:18:44,190 So I'm going to pass the new ticket number over there as well. 282 00:18:44,530 --> 00:18:45,190 Nice. 283 00:18:46,360 --> 00:18:48,730 And DataDot Card. 284 00:18:49,060 --> 00:18:53,380 I want to calculate the price gouging price. 285 00:18:53,770 --> 00:18:55,470 I want to calculate new price here. 286 00:18:55,990 --> 00:19:01,380 These are a movie that no ticket is good for. 287 00:19:01,750 --> 00:19:04,750 Now let's create first in the movie. 288 00:19:05,050 --> 00:19:11,470 I want to create a function that we just wrote it down and it will be somewhere over here and it will 289 00:19:11,470 --> 00:19:15,130 see update from the card in here. 290 00:19:15,130 --> 00:19:16,340 I will pass the number. 291 00:19:17,770 --> 00:19:24,280 Now these that tickets actually number tickets equal to that number over there. 292 00:19:24,670 --> 00:19:25,140 Nice. 293 00:19:25,360 --> 00:19:27,280 So we are done with this one. 294 00:19:27,280 --> 00:19:32,920 Go back to the card now and create the second function for calculating the price, because here we just 295 00:19:32,920 --> 00:19:33,580 have the price. 296 00:19:33,580 --> 00:19:35,190 We are not increasing the price. 297 00:19:35,680 --> 00:19:37,050 So that is pretty much it. 298 00:19:37,330 --> 00:19:42,250 And let's say Colque price in here, we do have number of tickets. 299 00:19:44,320 --> 00:19:57,190 Now, these that price will be equal to pass int number of tickets that we are passing from the function 300 00:19:57,190 --> 00:20:02,790 here times 10, because we already know that the price is going to be ten nice. 301 00:20:02,830 --> 00:20:03,540 So let's save it. 302 00:20:03,790 --> 00:20:06,340 And here I'm going to have again another problem. 303 00:20:06,340 --> 00:20:12,790 So maybe I should tackle this solution a little bit differently to make this one hover, but I'll leave 304 00:20:12,790 --> 00:20:13,220 it to you. 305 00:20:13,820 --> 00:20:17,200 So, yeah, let's see if it's going to work or not. 306 00:20:17,200 --> 00:20:17,680 Movie. 307 00:20:18,550 --> 00:20:19,660 I'm just going to add it here. 308 00:20:20,590 --> 00:20:24,450 I'm just going to buy one ticket from this one by actually. 309 00:20:24,460 --> 00:20:25,000 That's enough. 310 00:20:25,510 --> 00:20:31,870 Buy one ticket in here when I see two here and if I hit enter right. 311 00:20:32,080 --> 00:20:34,270 Or if I go outside of this one. 312 00:20:34,600 --> 00:20:36,700 So what I can do, inspect element. 313 00:20:37,510 --> 00:20:40,620 I want to go to the data and to see if something has changed here. 314 00:20:40,900 --> 00:20:46,060 So data that card first it is the price is twenty because I have two times ten. 315 00:20:46,390 --> 00:20:46,930 Nice. 316 00:20:47,230 --> 00:20:48,280 That is working. 317 00:20:51,110 --> 00:20:51,500 Right. 318 00:20:51,650 --> 00:20:57,090 Let me show you, so the price is 10, but actually we set the price back to 20. 319 00:20:57,350 --> 00:20:57,720 Good. 320 00:20:57,740 --> 00:20:58,440 It's working. 321 00:20:58,760 --> 00:21:05,180 Now, what else we need here is to check the data, that movie and see if we have two tickets here, 322 00:21:05,180 --> 00:21:08,410 because at the at the beginning, we just entered one. 323 00:21:08,960 --> 00:21:10,670 And let's look at the data. 324 00:21:10,670 --> 00:21:16,530 That movie, that number of tickets here is ladies and gentlemen, and it's working. 325 00:21:16,820 --> 00:21:21,620 So if you just increase to this one and if you go sometimes it will not work straight away. 326 00:21:21,620 --> 00:21:23,750 But you need to just click, enter or whatever. 327 00:21:24,110 --> 00:21:29,810 And now if I go back here and hit enter, I will have the number of tickets three. 328 00:21:30,050 --> 00:21:34,940 And if I go data that card, the price will be thirty. 329 00:21:35,240 --> 00:21:35,620 Right. 330 00:21:37,670 --> 00:21:39,270 And that is pretty much it. 331 00:21:39,290 --> 00:21:40,670 So I just grab that price. 332 00:21:40,670 --> 00:21:47,330 I just incremented and I hope you are happy with the outcome so we can successfully this one. 333 00:21:48,140 --> 00:21:48,920 We can go out. 334 00:21:49,130 --> 00:21:50,600 We have decreased this one. 335 00:21:50,810 --> 00:21:53,780 We are just able to add items in our car. 336 00:21:53,990 --> 00:22:00,770 We will able to delete using these glasses and calculate price here first in the movie. 337 00:22:01,400 --> 00:22:07,040 I also add the price here, then in the card view, we actually haven't added nothing in the card view. 338 00:22:07,160 --> 00:22:10,100 So we have that one function here and one function here. 339 00:22:10,640 --> 00:22:11,330 That's pretty much it. 340 00:22:11,330 --> 00:22:14,070 That will be our final logic here. 341 00:22:14,090 --> 00:22:15,710 Now you can create more functions if you want. 342 00:22:15,900 --> 00:22:16,240 Right. 343 00:22:16,940 --> 00:22:17,810 And that's pretty much it. 344 00:22:17,840 --> 00:22:22,730 Now we do have event Lisandro for updating and deleting the card. 345 00:22:23,360 --> 00:22:23,810 Right. 346 00:22:24,140 --> 00:22:33,560 And we do have this listener here that we are just calling the card controller and the controller have 347 00:22:33,560 --> 00:22:33,830 this. 348 00:22:33,870 --> 00:22:39,060 Now, if some of the things is not working, just make sure that you grab from the final version. 349 00:22:39,200 --> 00:22:40,340 See what I have done. 350 00:22:40,670 --> 00:22:46,760 And yeah, just compare it in probably there is some minor mistake somewhere that's not working. 351 00:22:46,790 --> 00:22:56,240 See, in the card view, we do have that movie movie, the title in here without one quotes and it wasn't 352 00:22:56,240 --> 00:22:56,930 working right. 353 00:22:56,930 --> 00:23:00,020 So only two minor mistakes, but four JavaScript. 354 00:23:00,020 --> 00:23:01,910 That is enough not to execute things. 355 00:23:02,180 --> 00:23:05,210 OK, so I will see you in the next lecture and enjoy.