Getting Started with Knockout.js for .NET Developers by Akinshin Andrey

Getting Started with Knockout.js for .NET Developers by Akinshin Andrey

Author:Akinshin, Andrey [Akinshin, Andrey]
Language: eng
Format: azw3, epub
Publisher: Packt Publishing
Published: 2015-05-26T16:00:00+00:00


Let's discuss some of the updates in detail.

The initialization logic of the model is in the constructor of the controller.

The GetBooks and the GetName methods were removed because now we can bind to the corresponding data directly via the model, with the help of Knockout MVC.

The [HttpGet] Edit method turned into two methods: Edit and EditRedirect. The new Edit method just returns the Edit view for the target book by index. The EditRedirect method returns a special redirect object in the JSON format. The object contains two properties: redirect=true (which means that we want to perform a redirect on this action) and url (which contains the target URL). The [HttpPost] Edit method for the Edit view remains the same.

The Add and Remove methods now take an additional LibraryModel argument. The argument stores the entire model obtained from the client (because Knockout MVC sends the entire model on each such requests). In the bodies of these methods, we update the static Library property with the client version of the model (let's recall that the static Library property symbolizes the main data source; for example, it can be a database in the real application).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.