The last thing that we want to do is create a function here, that group responsible to delete that
product.
So I would call this function delete.
And let's say here we've passed a euro that we have to invoke to hit our endpoint and take the product
controller, which is right here.
So let me switch back here.
We want to call sweet alert.
So if we go back to your browser and search for tweet alert in the example, let me search for 10 because
we want to wait for a response.
Let us try this.
Not that.
Let me scroll down.
I think this one is much better audio show.
Yes, delete.
Then we want a notification that will copy the sweet alert and we will paste that in our function.
When the result is confirmed, we do not quantify a Newsweek alert.
We will have to make an Ajax request to hit that endpoint for delete.
So we will say Ajax here.
Inside there, we want to hit a wall.
Thank you what we received in the parameter here.
We will use that next.
That time will be delete because if you examine the controller, we have HTP delete after that on success,
we want to create a function that will receive some data.
Now, if you examine the product controller and Jason, we are passing some data on error as well as
successful deletion.
So we will receive that data here and on that data, if we go back, we have a property with the name
of success and message so we can see here if data are success.
If that is true, then we want to use the toaster notification.
We added that toaster on discord layout so we can use that we will adjust the toaster, that success
and we will display data that message in the Allspark.
We have some error.
So we will display a toaster, that error and data anti-tax message.
One thing that I want to do is if the delete was successful, I want to reload our data table.
So we have that.
In fact, the variable data table.
So right here we can see a data table that Ajax that reload with that change.
Let me save everything and run the application.
Let me add a debugging point inside the delete endpoint now with twenty twenty two.
We have something known as temporary break point.
You just need to right click here and we can insert a temporary breakpoint once this breakpoint has
head, that will go away.
That way, we do not have to worry about the hassle of removing the breakpoint every time.
Let's go to product here and let me create a new temporary product.
That shows an image.
And hit the Create button.
Let's try the delete.
When we hit delete here, we do not get any sweet alert.
And of course, we will not get that.
We added this function of delete, but did we call it on the delete button?
We did not.
So instead, this anchor tag we want to call it on.
Click here, and we want to invoke the delete function.
Here we need to pass that you are L.
That is inside admin.
We have product and then we need to pass the I.D. supplier's dollar.
We will pass that data, which has the idea of the product that needs to be deleted.
That can save this.
Go back and refresh and hit delete one more time.
Perfect.
We have suite alert here.
If you click on cancel and nothing happens, let's try to hit delete and it should hit an endpoint that
it does not.
Let me see what happened here.
We have an error.
Let's see that.
Thank you, are out is incorrect.
Let me go back here and after product, we need to add the action method name, which is to lead, but
see that right here.
Also, this quote will not be here.
It will be after the data like this.
With that, let me see if that changes.
Let's go back and refresh here.
Let's try this one more time and perfect radar break point.
The image is also getting deleted, product is removed from the database and we go back.
Delete was successful.
So with this, all the current operations on product are now working successfully.
We spent a lot of time on product, but if you examine we have done things way differently now, we
have a nice day at our table here when we are creating a product.
We have emerged that we are taking care of.
We have dropdowns where we saw a few back view data and view models.
So everything is working as expected.
One last thing I noticed here is packed list is taking it back to cover tape.
Let me fix that.
So insert the absurd page here, if we scroll down where it is that there should be tracked.
So with that, we have done with the product.
Let's continue from the next section.