Knockout provides an elegant way of updating the user interface using Javascript View models. Javascript has an inheritance model. With that, we can create a hierarchy of classes. Consider the following HTML with Knockout bindings.

<div id="main">
    <div data-bind="text: name"></div>
    <div data-bind="text: detail"></div>
</div>

We use a simple Model class. Load it with data. And bind it to the HTML.

var model = new Model();
model.load();
Read More

Knockout is a UI framework for building single page apps. In Knockout, observable and observableArray are two basic functions. Observable enables two-way binding between the UI and the data in View Model.

ObservableArray stores a collection of View Models. When a View Model is added or removed from the array, the bindings are re-evaluated. And the UI is re-rendered. Most of the array operations are supported.…

Read More

Knockout.js is a good framework for building single page applications. But, it has a few drawbacks. But before going over the drawbacks, we will discuss the problem that it solves.

Too many View Models

With Knockout.js, we create a View Model. Then bind the View Model to the HTML elements. Whenever the data within the View Model changes, the framework updates the view or HTML elements.…

Read More

Knockout.js is a client-side Javascript framework for creating single page applications. Central to the framework is the VIewModel. ViewModel represents the model or data for the View. It also has the behavior of the view. Click event handlers are part of the ViewModel.

DOM elements (View) are bound to ViewModel. We create a simple ASP.NET MVC application which displays a DropDown.…

Read More