Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Getting Started with Knockout.js for .NET Developers
Getting Started with Knockout.js for .NET Developers

Getting Started with Knockout.js for .NET Developers: Unleash the power of Knockout.js to build complex ASP.NET web applications

eBook
$23.39 $25.99
Paperback
$32.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Getting Started with Knockout.js for .NET Developers

Chapter 1. Introduction to Knockout.js

Knockout.js is a popular JavaScript library that allows easy creation of powerful web applications based on the Model-View-ViewModel (MVVM) design pattern.

In this chapter, we will cover the following topics:

  • Knockout.js overview
  • Installing Knockout.js
  • Knockout.js fundamentals

Knockout.js overview

In this section, we will take a look at Knockout.js, including a brief introduction and the best features. If you already have some experience with the library, then you can skip this chapter and go to Chapter 2, Creating a Simple Knockout.js Application, to read about the advanced features.

What is Knockout.js?

Knockout.js is an open source standalone JavaScript library developed by Steve Sanderson in 2010. The main concept of the library is implementation of the Model-View-ViewModel design pattern for web applications on the client side. The library has powerful tools to make your JavaScript code and HTML/CSS markup easier and more readable with the help of so-called observables objects and declarative bindings.

Thus Knockout.js can help you create rich HTML pages with a clean underlying data model and dynamically self-updatable UI even for very big applications with complex logic and interfaces.

The best features

Knockout.js has a lot of features that distinguish it from other similar JavaScript frameworks. There are different solutions to create the common logic of your application and interaction between data and user interface. When you select the main library to build an application, you should understand its benefits.

The following are the best features of Knockout.js:

  • Nice dependency tracking based on MVVM: Once data is changed, HTML will be automatically updated. You shouldn't think about updating DOM when writing logic code. We will discuss the MVVM pattern in more detail later.
  • Two-way declarative bindings: This is a very simple way to link DOM elements to your data model, as shown in the following line of code:
    <button data-bind="enable: items().count < 7">Add</button><input data-bind="value: username" />
  • Simple and extensible: You can write your own type of declarative bindings for any purpose. Each new binding is defined by two simple functions for the init and update events. For example, you can define a binding for the duration of a slide animation, as follows:
    <div data-bind="slideDuration: 600">Content</div>
  • Absence of dependency: You don't need any third-party libraries. However, you may need the jQuery library for some advanced features support or performance issues, but most applications already use this library.
  • Pure JavaScript: Knockout.js doesn't use any JavaScript superstructure, such as TypeScript or CoffeeScript. The source code of the library is represented by the pure and readable JavaScript code; it works with any server- or client-side technology.
  • Compatibility with mainstream browsers: Knockout.js supports Mozilla Firefox 2+, Google Chrome 5+, Opera 10+, Safari, and even Internet Explorer 6+. It also works excellently on mobile (phone and tablet) devices.
  • Small size: The size of Knockout.js is around 46 KB after gzipping for version 3.1.0. The debug versions (without compression) have a size of around 214 KB but you don't need it in the production case.
  • Templating: The powerful template system will allow you to create reusable HTML chunks, which you can use for parts of a web page. It also has a nice syntax, as shown in the following code:
    <script type="text/html" id="person-template">
        <h3 data-bind="text: name"></h3>
        <p>Credits: <span data-bind="text: credits"></span></p>
    </script>

MVVM design pattern

The Model-View-ViewModel is a design pattern with a clear separation of the user interface from business logic. The main components of MVVM are as follows:

  • Model: This represents the state and operations of your business objects and is independent of UI. When using Knockout.js, you will usually make Ajax calls to some server-side code to read and write this stored model data.
  • View: This is a visible UI representing your business objects.
  • ViewModel: This is an intermediary between the View and Model, and is responsible for handling the UI logic.

You can see the scheme of MVVM in the following diagram:

MVVM design pattern

The MVVM pattern looks like the classic Model-View-Controller (MVC) pattern. The Model is also your stored data, the View is also a graphical representation of your data for the user, but instead of a controller, MVVM uses a ViewModel for interaction between the Model and View. The MVVM has a number of advantages over the MVC, such as the following:

  • Low coupling: It's a property of the MVVM by design, because of which we use a clearer separation between the data, interface, and behavior. MVVM has a clearer separation between the data, interface, and behavior for most application architectures.
  • Testable: Low coupling makes the application more comfortable for unit-testing; now you can separately test each layer of your application. Testing UI logic by testing only ViewModel is an easier way than testing a complete HTML page.
  • Сode extensibility: Separation by layers makes it easier to extend each specific part of the code without affecting the others.
  • Two-way data-binding: This avoids having to write a lot of boilerplate code.

Let's consider MVVM in examples. In parentheses, you can see the representation format of each layer, but note that these are just examples; different applications use different formats:

  • Knockout.js: This is the target case for this book. Most often, a Knockout.js application will use the following schemes:
    • Model: This includes some data on the server side; you can read and write it via Ajax calls (JSON).
    • View: This is the web page (HTML/CSS).
    • ViewModel: This is the representation of data and operations (JavaScript).
  • WPF: Many .NET developers are familiar with MVVM on technologies such as WPF, Silverlight, and WinRT. Originally, the MVVM pattern was conceived to support WPF and Silverlight. For example, you can use the following scheme in your WPF application:
    • Model: This includes some data in the client database (binary)
    • View: This is the user interface of the WPF application (XAML)
    • ViewModel: This is the special data context classes (C#)

In this book, we will not explain MVVM in detail because the easiest way to understand MVVM is a careful study of the examples in this book. The examples will work only with View and ViewModel because communication with a real data model (commonly, some data on the server, which can use SQL, RSS, XML, binary, and so on) is another story. Within these examples, you can consider the ViewModel as the Model as well because it actually holds all your data. In a real application, you should select a way to transfer this data to the server.

Installing Knockout.js

There are a few ways to install Knockout.js, and each method is outlined here. Generally, you want to use the first or second method, but the third and fourth methods can be useful in some special cases.

Method 1 – official site

You can manually download Knockout.js from the official site http://knockoutjs.com/. You can see the screen of the main page in the following screenshot:

Method 1 – official site

After downloading, you can add a reference to Knockout.js from your HTML page using a <script> tag. For example, if the library was downloaded to the root directory of your application, then you can use the following line of code:

<script type='text/javascript' src='knockout-3.1.0.js'></script>

You should use the actual version of the library instead of version 3.1.0 (released in March 2014) in the preceding example line of code. Hereafter, we will use version 3.1.0 (it is the current version at the time of writing this book), but because of backward compatibility all examples should work with future Knockout.js versions very well.

Also, you can download the debug build for learning purposes (from the download page at http://knockoutjs.com/downloads/index.html). It helps you to understand how Knockout.js works. Don't use it for real production applications.

Method 2 – NuGet

If you develop a website with .NET, you can install it via NuGet (https://www.nuget.org/packages/knockoutjs). Just run the following command in the Package Manager Console:

Install-Package knockoutjs

Method 3 – CDNs

Content distribution network (CDN) is a large system for delivery or distribution of some content to end users' servers. You can use third-party CDNs for reference Knockout.js. Examples of CDNs can be found at http://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js and http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.0.0.js.

Note that not all CDNs support the latest actual version of the library. The best way is to use a local library version on your server, but the CDNs method can be very useful for quick single-page solutions.

Method 4 – GitHub

Full sources of the library are placed on GitHub at https://github.com/knockout/knockout. You can build the latest Knockout.js version from source by yourself by executing the following steps:

  1. Clone the repo from GitHub. Make sure that you have Git installed on your local machine:
    git clone https://github.com/knockout/knockout.git
    cd knockout
    
  2. Acquire build dependencies. Make sure that you have Node.js installed on your local machine:
    npm install -g grunt-cli
    npm install
    
  3. Run the build tool:
    Grunt
    

Done! Now you can find the built files in the build/output/ directory.

Knockout.js fundamentals

In this section, you will learn how to create a very simple "Hello World" application with step-by-step instructions. Each step will describe one of the main Knockout.js concepts.

Creating a View

Let's learn about Knockout.js with a very simple example. We start work with the following code of an HTML page (HelloWorld-Example1.html):

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Hello world on Knockout.js</title>
  </head>
<body>
<span>Hello World!</span>

<script type='text/javascript' src='knockout-3.1.0.js'></script>
</body>
</html>

If we open this page in our favorite web browser, we will see the blank page with a single line, Hello World!. The body of this HTML page is the View layer of our MVVM pattern.

However, we did not use Knockout.js in this example. Let's change it.

Adding a ViewModel

Let's add some JavaScript code to our example. We will move information about the printed string from the View layer (HTML page) to the ViewModel layer (JavaScript object):

<script type='text/javascript'>
  var viewModel = {
    message: "Hello world!"
  };
  ko.applyBindings(viewModel);
</script>

In this example, the viewModel is a simple JavaScript object with a single message property. In the last line of the script, we activated Knockout.js by the applyBindings method of a global Knockout.js object called ko. The first parameter takes the ViewModel object that you want to use.

It's time to connect ViewModel with our HTML.

Adding a data binding

Let's change the inline Hello World! string to an empty span element with data binding (the full code of the page is placed in HelloWorld-Example2.html):

<span data-bind="text: message"></span>

The syntax of Knockout's declarative bindings provides a powerful way to link your data (the View) with your UI (the ViewModel). You can see an example of such syntax in the preceding HTML line; it consists of two parts (as a value of the data-bind property), the binding name and value, separated by a colon. In the example, we bind the text property of the span element to the user-defined message property of ViewModel.

Because of the message property, the content of the span element is Hello world!. The rendered HTML page is still represented by a single text line.

Adding an observable

Now our example has one thing lacking: changes of the ViewModel don't link to changes of the View. We can improve the situation with observables. Let's update the viewModel definition (see HelloWorld-Example3.html):

var viewModel = {
  message: ko.observable()
};
viewModel.message("Hello world!");
ko.applyBindings(viewModel);

In this example, message is an observable property. It means that after any changes to the message property, UI elements with corresponding bindings will be automatically updated.

You should understand that the ko.observable properties are actually functions. Therefore, you can use these functions to read and write. If you want to write some value in a property, you should call an observable function with a new value as the first parameter (such as in the preceding listing). If you want to read a value from a property, you should call the observable function without any parameters:

viewModel.message("Hello, world!");   // Write operation
currentMessage = viewModel.message(); // Read operation

The observables are the most important part of the Knockout.js MVVM structures. All of your ViewModel properties that are involved in the UI update process should be defined as an observable (such as in the preceding code via ko.observable). A non-observable property will work only for one-time read-only data binding. It may be useful for some special cases, but generally, you should describe all of your ViewModel properties as observables.

Also, you can set the initial observable value directly in the definition (for example, message: ko.observable("Hello world!")).

Subscribing to observables

Most applications don't need an explicit way to subscribe to observables (such operations are performed implicitly using the declarative style), but in some special scenarios, it may be useful. Now we consider the explicit way for a better understanding of the observables concept.

Explicitly subscribing means declaring a callback with the subscribe function, as shown in the following example (see HelloWorld-Example4.html):

viewModel.message.subscribe(function(newValue) {
  alert("New message is " + newValue);
})

After this subscription, any changes to the message property would entail an alert message about the changes.

In a real application, it may be useful to create an additional logic for the observable property change event that you can't make by the usual declarative bindings.

Updating View in a forced way

A data binding can have additional properties. Let's consider an example. By default, the View layer gets a notification about data changes only if the data was actually changed. However, we can modify this behavior and make ViewModel always send notifications. For this purpose, you will use the so-called notify extender to ensure that our subscribers are always notified on a write request, even if the new property value is the same:

viewModel.message.extend({ notify: 'always' });

In the preceding line of code (see HelloWorld-Example5.html), we call the extend function to update the notify property of message by the always value.

In a real application, it may be useful if you want to notify a user about any change operation of data, regardless of a new value.

Delaying and suppressing change notifications

Let's consider another extender example. Normally, an observable notifies its subscribers immediately, as soon as it's changed. However, if an observable is changed repeatedly or triggers expensive updates, you may get better performance by limiting or delaying the observable's change notifications, as follows:

viewModel.message.extend({ rateLimit: 100 });

In the preceding line of code (see HelloWorld-Example6.html), we call the extend function to update the rateLimit property of message by 100. It means that ViewModel will notify the View about changes no more than once in every 100 milliseconds.

Adding dynamic behavior

It's time for a more interesting example. We will add some dynamic behavior. Let's insert a button to add an exclamation mark to our message. The new representation of the View layer will be as follows:

<span data-bind="text: message"></span><br />
<button data-bind="click: addExclamationMark">Add exclamation mark</button>

The representation of the ViewModel layer will be as follows:

var viewModel = {
  message: ko.observable(),
  addExclamationMark : function() {
    this.message(this.message() + "!")
  }
};
viewModel.message("Hello world!");
ko.applyBindings(viewModel);

In the View, we can see the button with the new declarative binding: click. This binding expression sets the click button event handler to addExclamationMark. We can find the declaration of this function in the ViewModel:

  addExclamationMark : function() {
    this.message(this.message() + "!")
  }

In the body of the function, we used the message property twice: once to read and once to write. More specifically, we took the current value of message, added an exclamation mark to the obtained string value, and set the composite string as the new message value.

Try to run the example (HelloWorld-Example7.html) and click on the button. You will see how the message is modified, as shown in the following screenshot:

Adding dynamic behavior

A binding diversity

There are different ways to use Knockout.js declarative bindings. We will consider it in the following chapters, but for now, you can briefly look at the following binding example to understand the diversity of opportunities that you have with Knockout.js. You can find the full list of examples with comments in the BindingDiversity.html file.

Single and multiple bindings

An element can use a single binding (described by the name and value) or multiple bindings (related and unrelated). In the last case, each binding should be separated from the previous one by a comma:

<!-- Single -->
<span data-bind="text: message"></span>

<!-- Multiple related -->
<input data-bind="value: name, valueUpdate: 'afterkeydown'" />

<!-- Multiple unrelated -->
<input data-bind="value: name, enable: isNameEnable" />

Value representation

The value of a binding can be represented by a single value, variable, or literal. In addition, you can use some JavaScript expressions, including function calls, as shown in the following code:

<!-- Variable -->
<div data-bind="visible: shouldShowMessage">...</div>

<!-- Simple expression + value -->
<span data-bind="text: price() > 50 ? 'expensive' : 'cheap'"></span>

<!-- Functional call -->
<button data-bind="enable: parseAreaCode(cellphoneNumber()) !== '555'">...</button>

<!-- Function expression -->
<div data-bind="click: function (data) { myFunction('param1', data) }">...</div>

<!-- Object literal -->
<div data-bind="with: {emotion: 'happy', 'facial-expression': 'smile'}">...</div>

Note that such examples demonstrate a kind of bad practice because the good way encapsulates all the logic in the ViewModel layer.

White spaces

White spaces (spaces, tabs, and newlines) do not affect bindings. The following examples are all equivalent:

<!-- Without spaces -->
<select data-bind="options:availableCountries,optionsText:'countryName',value:selectedCountry,optionsCaption:'Choose...'"></select>

<!-- With spaces -->
<select data-bind="options : availableCountries, optionsText : 'countryName', value : selectedCountry, optionsCaption : 'Choose...'"></select>

<!-- With newlines -->
<select data-bind="
    options: availableCountries,
    optionsText: 'countryName',
    value: selectedCountry,
    optionsCaption: 'Choose...'"></select>

Skipping the value

If you use Knockout.js 3.0+, you can use the binding without a value, as shown in the following code. In this case, binding will have an undefined value. It can be useful with binding preprocessing (you will learn about this feature in future chapters):

<!-- Without a value -->
<span data-bind="text">Text that will be cleared when bindings are applied.</span>

Useful links

You can find more useful information about Knockout.js at the following links:

Information about Knockout.js developers can be found at the following links:

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Summary

In this chapter, we got acquainted with Knockout.js, what it is what its benefits are, how to download and install it, and how to write a simple "Hello World" application. In addition, we covered the MVVM design pattern and how it helps us to build a nice application with the help of Knockout.js. The Hello World example demonstrates basic Knockout.js features, such as observables, data bindings, subscribing logic, and its extenders.

Left arrow icon Right arrow icon

Description

This book is intended for .NET developers who want to use the MVVM design pattern to create powerful client-side JavaScript linked to server-side C# logic. Basic experience with ASP.NET, Razor, and creating web applications is needed.

Who is this book for?

This book is intended for .NET developers who want to use the design pattern to create powerful client-side JavaScript linked to server-side C# logic. Basic experience with ASP.NET, Razor, and creating web applications is needed.

What you will learn

  • Work with observable arrays, special bindings, and computed observables
  • Create a model in C# and connect it with the MVVM structure in JavaScript
  • Integrate the Knockout.js library into ASP.NET applications
  • Configure tmux and customize it for your needs
  • Migrate your entire business logic to the server side with Knockout MVC
  • Understand and use basic MVVM concepts such as declarative bindings and observable properties
  • Discover special Knockout.js concepts such as regions, complex bindings, combined contexts, and more
  • Leverage the key features of Knockout.js such as declarative bindings, templating, and dependency tracking in ASP.NET applications
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 27, 2015
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781783984008
Vendor :
Microsoft
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : May 27, 2015
Length: 188 pages
Edition : 1st
Language : English
ISBN-13 : 9781783984008
Vendor :
Microsoft
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 120.97
KNOCKOUTJS BLUEPRINTS
$32.99
Getting Started with Knockout.js for .NET Developers
$32.99
MASTERING KNOCKOUTJS
$54.99
Total $ 120.97 Stars icon

Table of Contents

8 Chapters
1. Introduction to Knockout.js Chevron down icon Chevron up icon
2. Creating a Simple Knockout.js Application Chevron down icon Chevron up icon
3. Integrating Knockout.js in ASP.NET MVC Applications Chevron down icon Chevron up icon
4. Creating a Web Application with Knockout MVC Chevron down icon Chevron up icon
5. Advanced Features of Knockout.js Chevron down icon Chevron up icon
6. Advanced Features of Knockout MVC Chevron down icon Chevron up icon
A. A Brief on Knockout MVC References and Features Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(9 Ratings)
5 star 66.7%
4 star 11.1%
3 star 11.1%
2 star 0%
1 star 11.1%
Filter icon Filter
Top Reviews

Filter reviews by




Scooter Sep 09, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I recently started a new job with a web development that uses knockout. I’ve never used it before and this book was a good supplement while getting my feet wet.
Amazon Verified review Amazon
J Jul 13, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was immediately interested in this book as I have used Asp.Net Ajax since its creation and for quite a while have been looking to seriously move to MVC. The first two chapters covered the Knockout basics very well including highlighting and explaining types of Observables. Chapter 3 had plenty of description although at the end of the chapter I didn’t fully understand all aspects of the view scripts.Moving on to chapter 4 and Asp.Net Knockout MVC it became really interesting as I use server side Ajax and there was a clear description of when Knockout MVC should be used and when not to use. In this chapter the Observables disappeared as handled on the server side but it would have been helpful for a fuller description considering their importance. Other than that, the topic was comprehensive.All the above chapters (1 to 4) had code to download which is always appreciated as it allows concentrating on learning and not typing - and eliminating typing errors.Chapter 5 moved on to advanced features in Knockout .js whilst chapter 6 was advanced features in Knockout.MVC. Both were handled well and covered topics I was unaware but would have been much improved if there had been code downloads.And finally the last section of the book forms a Knockout reference.Overall a book recommended for those learning Knockout, especially from an Asp.Net background. The only real criticism was the lack of code download for two chapters.
Amazon Verified review Amazon
Joseph J. Waldner Aug 03, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really love this book! It is clear, concise and takes things in small understandable steps. More advanced books will be clearer after this book [I think]. Great for people who need to get familiar with knockout fast.
Amazon Verified review Amazon
Mark Jul 06, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Chapter 3 make this the book totally worthwhile. In this chapter, the author created an MVC example that used Knockout and the I/O calls to load data into the page were performed through JavaScript/AJAX calls made against Web API controllers in the project. I'm comfortable with heavy duty JavaScript more than I am MVC syntax so this was a plus.The author didn't do like everyone else and populate the page with data from the view model passed into the view through the controller - instead he used jQuery Ajax calls to perform I/O. I liked the author didn't fluff the book with 20-or more pages with orientations on EF and or how to setup code-first repositories.The author focused on how the code should be architected to use MVC with Knockout. As a .NET Web Developer, I needed to choose between using Knockout or AngularJS to reduce code that I previously wrote to maintain state back to the server. I chose Knockout because our biggest customers are on IE8 and Knockout supports IE6 and above. The code example carried throughout the book was a simple home library inventory - I liked that better than an overly complex one like an online store. For me, this book was a good place to start learning Knockout.
Amazon Verified review Amazon
A. Struthers Feb 20, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent read. Great resource to have it you are wanting to jump into KnockOut.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon