The third feature of this application is about adding a product to 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 add a new product
Update the product model to add a flag to switch the product between edit and display mode
Update the products grid module to create a method to add a product
Update the products grid module to create a method to save the product
Update the view to create a link to add a product and capture user input
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 POST
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 DELETE
request, use the $.ajax()
method provided by jQuery to send the HTTP POST...