The final feature of this chapter is about updating a product in 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 update a product
Update the products grid module to create a method to edit a product
Update the products grid module to create a method to update the product
Update the view to create a link to update the product
Let's get started by updating the ProductsClient
module. Open the ProductsClient
module in the productsclient.js
file and add a method to send HTTP PUT
request to http://[host:port]/products
. 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 PUT
request, use the $.ajax()
method provided by jQuery to send the HTTP POST
request. Add a data
parameter to the object passed to $.ajax()
and assign it the product model as a JSON string...