O'Reilly logo

Getting Started with Knockout.js for .NET Developers by Andrey Akinshin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Form fields bindings

Forms are important parts of many web applications. In this section, we will learn about a number of data bindings to work with the form fields:

  • The value binding
  • The click binding
  • The submit binding
  • The event binding
  • The checked binding
  • The enable binging
  • The disable binding
  • The options binding
  • The selectedOptions binding

The value binding

Very often, forms use the input, select and textarea elements to enter text. Knockout.js allows work with such text via the value binding, as shown in the following example (PersonalPage-Binding-Value.html):

The Model will be as follows:

var person = {
  firstName: "John"
};

The ViewModel will be as follows:

var PersonViewModel = function() { var self = this; self.firstName = ko.observable(person.firstName); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required