All right, improvers lecture, we have programmed how to display final results of user results list
on admin panel as a result has the lead button on the right side.
So just like you were going to give the functionality to that button in order to delete results from
results released.
So first, I'm going to use event listener.
But as it was previously, we will attach it to your results list wrapper and then event object target
property and it will help us to find out which users delete button was clicked.
So it was a little hint because I'm going to give you it again as a task.
I recommend you to take a look at first on added questionnaires function so that pause the video and
try to do it on your own.
All right, let's go ahead and attach event listener to resultantly the rapper and of course, do it
in control module the right selected items.
That results list rapper.
And this year event listener with click event.
And also right here on this function.
After that, let's go to UA controller module and create new method, let's call it dilator results.
That use your anonymous function.
Which will hold two parameters, as we mentioned, we will need to use event object, so as a first
parameter, let's place your event then as a second parameter.
Because of that, we will need to get access on personal local storage.
Let's insert your user data.
OK, now let's go to comptroller module again and invoke this function.
Right, EUA controller.
That the result?
So as I first argument, when this event objects at first, let's place it in anonymous function as
a parameter and then insert it here as well as for the second argument, we need to get access on personal
local authority.
So that's right, Chris Controller, that gets person local authority.
All right.
We want the code to execute when admin will click on delete button.
So for that, we had to use if statements.
And before we actually right the condition, let's take a look on both elements in previous function,
it has attributes which includes two parts DELYTH result and which is common for all the buttons and
the number of parts which actually is defined using person ID.
Using those parts, we will be able to define it for each delete button.
So for that as a condition, we have to write the following digit result with an.
And in order to find out if clicked elements, I includes this part, we need to use index of method.
Which as an argument, will get events that target.
That ID.
So if this condition is true, then we will get the no part from the idiot, and for that let's declare
new variable and call it gets idee.
So we need to get the no part from you attribute, and for that, as you remember, there is a great
way in JavaScript I made this split method which actually splits string and returns.
Right with two items from that array.
We need to use second item.
So let's.
Right.
Get ID equals.
So event dot target.
That ID.
And use your split method.
As I see it, the attribute includes multiple dashes.
So if we use your dash that it would split it up to delete, but actually we need to split it after
end.
And that's why we use your underscore.
OK, so we need from every second item, therefore here as index number, we have to indicate index
as one.
And also, in order to get the number of parts with data type as number, I'm going to use your first
aid method.
All right.
Let's test it, right, cancel that log.
Get ID.
Then go to Browsr and experts logging as a user in order to add one more result in results.
So let's do the quiz.
That.
Look out and log in as admin.
Click on delete buttons.
And you see that we have zero and one in council.
All right, so it works fine.
Let's move on to the next step.
Now we are going to get a rate of persons from local storage, then find using ID the result which we
want to delete, then delete it and overwrite new updated array to old one.
At first, let's be clear, a new variable and call it person's array.
And then assigned to it.
User data that got personal data.
We are storing personal data into variable not only for minimizing the amount, if we do not do it,
then person error won't be changed.
And in local storage, after setting Newera, we will still get the old one.
All right, so now we need to use follow up in order to iterate through the person's error and then
find out which is needed item the right variable, i.e. equal to zero.
That the condition is less than the length of a person's array.
And then I plus plus.
Inside Fallujah, we have to use if statement.
In which as a condition we have to define, if I'd of person object equals to get ID.
The right person, Sarah.
And I thought I'd.
Triple equals to get it.
So if this condition is true, it means that we have found the person and now it's time to delete it
for that, I am going to use this method.
So rights persons aura that supplies.
We need to place your two arguments, first one will be position from where we want to delete the item.
So let's place your eye.
And as a second argument, we need to indicate how many items we want to delete, therefore.
That's right.
You want.
So persons are right, is updated, and the last thing that we have to do is to overwrite this newly
updated array to old one on local storage, so.
Right.
User data.
That said, personal data.
And as an argument place, your persons are right.
All right, let's go to the browser, then login as admin.
So here we have two results.
Let's click on both the right buttons, you see that results are not remote because we need to reload
the page for that.
So log in as admin again.
And you see that results are deleted from that list, also, let's check local storage, go to application.
And you see that person's data is at.
All right, so the last thing to do in this video is to delete the results from results released dynamically
without any reloading the page.
For that, we just need to go to control controller module and after delete without function, invoke
add result on panel method.
So let's copy and paste here.
Then go to your browser.
Logging as user and.
Do the quiz.
Then log out and log in as admin.
Delayed results, and I said that it's remote result less dynamically.
All right, we're almost there to finish the application is very close because we just need to program
clear this button, so let's go ahead and do it.