SharpKit.KnockoutJs Namespace

Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably.

Download SDK: SharpKit.KnockoutJs.zip

Classes

Name Description
BindingHandler Represents a custom binding handler in Knockout.
DependentObservable<T> Represents an object containing a value dependent on other observable values.
DependentObservableOptions<T> Provides advanced options for defining a dependent observable.
Knockout Provides Knockout functionality.
KnockoutMapping Provides functionality for mapping between knockout models and JSON or vanilla script objects.
KnockoutUtils Provide access to utilities methods of the KnockoutJS
Observable<T> Represents an object containing an observable value.
ObservableArray<T> Represents an array of items that can be observed for changes to the set of contained items.

Interfaces

Name Description
IDisposable Represent a token to unsubscribe from observable subscription
IObservable Marker interface for observables.

Examples

Hello world
[JsType(JsMode.Global)]
class MyPage : Knockout
{
    static MyPage()
    {
        // Here's my data model
        var viewModel = new MyViewModel
        {
            firstName = observable("Planet"),
            lastName = observable("Earth")
        };
        // Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.
        viewModel.fullName = dependentObservable(() => viewModel.firstName.Value + " " + viewModel.lastName.Value);
            
        applyBindings(viewModel); // This makes Knockout get to work
    }
}
[JsType(JsMode.Json)]
class MyViewModel
{
    public Observable<string> firstName { get; set; }
    public Observable<string> lastName { get; set; }
    public DependentObservable<string> fullName { get; set; }
}
            
© Copyright 2005-2011 SharpKit. All rights reserved.