The second feature of this application is about deleting a product from the products grid. To implement this feature, we will:
Update the products client module to add a method to send a request to the server to delete a product
Update the products grid module to add a method to delete a product
Update the view to add a new column to the grid that will contain a button for the delete action
Let's get started by updating the ProductsClient
module. Open the ProductsClient
module in the productsclient.js
file and add a method to send an HTTP DELETE
request to http://[host:port]/products/{id}
. The method should expect the product model and a callback method as parameters. The callback method should get executed on successful response from the server. As used before to send the HTTP GET
request, use the $.ajax()
method provided by jQuery to send the HTTP DELETE
request. Don't forget to add the method to the return
statement of the ProductsClient
module. Our implementation looks...