Getting Started with Knockout.js for .NET Developers

Book description

Unleash the power of Knockout.js to build complex ASP.NET web applications

In Detail

Knockout MVC is a library for ASP.NET MVC that helps developers to move their entire business logic to the server.

With practical and accessible guidance, you will learn the skills necessary to successfully create Knockout.js-based applications of varying complexity.

Beginning with a vital overview of Knockout.js, including the MVVM design pattern, you will create a simple but powerful application capable of integrating with ASP.NET MVC as well as gain a thorough understanding of the Knockout MVC library. From this starting point, you will explore great advanced features that can be used in pure Knockout.js applications and server ASP.NET MVC logic, such as regions and complex bindings, as well as how to use the MVMM design pattern to create powerful sites separating the model, logic, and view layers.

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

  • Table of contents

    1. Getting Started with Knockout.js for .NET Developers
      1. Table of Contents
      2. Getting Started with Knockout.js for .NET Developers
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Introduction to Knockout.js
        1. Knockout.js overview
          1. What is Knockout.js?
          2. The best features
          3. MVVM design pattern
        2. Installing Knockout.js
          1. Method 1 – official site
          2. Method 2 – NuGet
          3. Method 3 – CDNs
          4. Method 4 – GitHub
        3. Knockout.js fundamentals
          1. Creating a View
          2. Adding a ViewModel
          3. Adding a data binding
          4. Adding an observable
          5. Subscribing to observables
          6. Updating View in a forced way
          7. Delaying and suppressing change notifications
          8. Adding dynamic behavior
          9. A binding diversity
            1. Single and multiple bindings
            2. Value representation
            3. White spaces
            4. Skipping the value
          10. Useful links
        4. Summary
      9. 2. Creating a Simple Knockout.js Application
        1. Creating the Model, View, and ViewModel
        2. Text and appearance bindings
          1. The text binding
          2. The html binding
          3. The css binding
          4. The style binding
          5. The attr binding
          6. The visible binding
        3. Form fields bindings
          1. The value binding
          2. The click binding
          3. The submit binding
          4. The event binding
          5. The checked binding
          6. The enable and disable binding
          7. The options binding
          8. The selectedOptions binding
        4. Control flow bindings
          1. The foreach binding
          2. The if and ifnot bindings
          3. The with binding
        5. Computed observables
          1. Using a computed observable
          2. Computed observable features
        6. Observable arrays
          1. Using an observable array
          2. Adding to an observable array
          3. Removing from an observable array
          4. Manipulating an observable array
        7. Summary
      10. 3. Integrating Knockout.js in ASP.NET MVC Applications
        1. Creating an application without Knockout.js
          1. Creating a new project
          2. Adding models
          3. Adding views
          4. Adding the Controller
          5. Running the application
        2. Creating an application with Knockout.js
          1. Motivation
          2. Creating a new project
          3. Adding models
          4. Adding views
          5. Adding the controller
          6. Running the application
        3. Summary
      11. 4. Creating a Web Application with Knockout MVC
        1. Getting started with Knockout MVC
          1. Motivation
          2. When you should use Knockout MVC
          3. Installation
          4. Useful links
        2. Working with the Hello World example in Knockout MVC
          1. Adding the model
          2. Adding the controller
          3. Adding the view
          4. Running the application
          5. Under the hood
        3. Developing a Knockout MVC application
          1. Adding the model
          2. Adding the controller
          3. Adding the view
          4. Running the application
          5. Under the hood
        4. Summary
      12. 5. Advanced Features of Knockout.js
        1. Loading and saving JSON data
          1. Converting data to JSON
          2. Converting JSON to data
        2. Introducing Knockout mapping
          1. A manual mapping example
          2. An automatic mapping example
          3. Mapping in Knockout MVC
          4. Mapping unique values
          5. Partial mapping – create
          6. Partial mapping – update
          7. Partial mapping – ignore
          8. Multiple mappings
          9. Advanced mapping
        3. Binding context
        4. Custom bindings
          1. Registering a new binding
          2. Binding callbacks' parameters
          3. A custom binding example 1 – slideVisible
          4. A custom binding example 2 – hasFocus
        5. Extending observables
          1. Creating an extender
          2. An extending observables example 1 – numeric
          3. An extending observables example 2 – required
        6. Custom functions
          1. An example with array filtering
        7. Different templating approaches
          1. A simple named template
          2. Template in the foreach mode
          3. The foreach template with alias
          4. Choosing a template dynamically
        8. Summary
      13. 6. Advanced Features of Knockout MVC
        1. Regions
          1. The foreach region
          2. The with region
          3. The if region
        2. Complex bindings
        3. Sending parameters to the server
        4. Inner computed properties
        5. Multiple view models
        6. Lazy loading
        7. Writing user scripts
        8. Summary
      14. A. A Brief on Knockout MVC References and Features
        1. Working with KnockoutContext
        2. Basic data binding
        3. Form objects
        4. Nested contexts
        5. Sending requests to the server
        6. Adding user-defined scripts
        7. Forming a model and using computed properties
        8. Special addressing forms
        9. Summary
      15. Index

    Product information

    • Title: Getting Started with Knockout.js for .NET Developers
    • Author(s): Andrey Akinshin
    • Release date: May 2015
    • Publisher(s): Packt Publishing
    • ISBN: 9781783984008