With the server taken care of, we can start consuming all this in the client. We will now be heading down the path of creating a ViewModel and hooking everything up.
Let's start by adding a JavaScript file sitting next to our index.html
file at the root level of the project, call it index.js
. This file will represent our ViewModel. Also, this scenario will be responsible for setting up KnockoutJS, so that the ViewModel is in fact activated and applied to the page. As we only have this one page for this sample, this will be fine.
Let's start by hooking up the jQuery document that is ready:
$(function() { });
Inside the function created here, we will enter our viewModel
definition, which will start off being an empty one:
var viewModel = function() { };
KnockoutJS has a function to apply a viewModel
to the document, meaning that the document or body will be associated with the viewModel
instance given. Right under the definition of viewMode
l
, add the...