Professional Documents
Culture Documents
Overview
What is KnockOutJS and why do I care? Getting Started Observables Bindings Templating Customizing KnockOutJS
What is KnockoutJS
Declarative Bindings Automatic UI Refresh Dependency Tracking Templating No Dependencies!
Model-View-View-Model (MVVM)
MVVM: Design pattern for building user interfaces Model Data of your application View Model Entity (field) structure of your data View UI that represents the View Model and the interactions within it
Learn More @ http://www.learnnowonline.com
Copyright by Application Developers Training Company
Overview
What is KnockOutJS and why do I care? Getting Started Observables Bindings Templating Customizing KnockOutJS
Getting Started
If using ASP.NET MVC 4
Good news, its part of the template!
In Visual Studio, open: Tools > Library Package Manager > Package Manager Console Type: Install-Package knockout.mapping
Overview
What is KnockOutJS and why do I care? Getting Started Observables Bindings Templating Customizing KnockOutJS
Observables
One of the 3 cores of KnockoutJS Allows reading and writing values Allows subscriptions (for notifying of a change)
Observables: Example
View Model in KO is easy, just declare your view model like the example below
var viewModel = { productName: Widget, productCat: Other };
Computed Observables
Allows customizations to View Model fields
function productsViewModel () { this.productName = ko.observable(Widget); this.productModel = ko.observable(12345);
Observable Arrays
Used for a collection of items
var myArray = ko.observableArray ([ { name: Windows, category: OS }, { name: Office, category: Application } ]);
Overview
What is KnockOutJS and why do I care? Getting Started Observables Bindings Templating Customizing KnockOutJS
Learn More!
This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details!