Skip to content
Anders Malmgren edited this page Dec 5, 2013 · 5 revisions

Welcome to the Knockout.Bootstrap wiki!

There is now a new version out called Knockout.Bootstrap.TemplateStore, it uses Owin for .NET. This repository is kept for none .NET systems.

Knockout.Bootstrap is a template bootstrapper for Single page applications. It utilizes a library called Knockout.BindingConventions which enables the library to resolve view names by ViewModel types. It understands that a ViewModel named CustomerViewModel should be connected to a view called CustomerView

The template bootstrapper is initialized like this

MasterViewModel = function() {
   this.bootstrap = ko.bootstrap.init(this, this.appStart.bind(this));
};

The object you send in as first argument must have a function called loadTemplates. This function is used to call for templates on the server.
The format of the returned object should look like

{ CustomerView: "Template Content" }

When the shared templates have been loaded the appStart function will be called and you can start your app

When you want to load a view you just call

this.bootstrap.loadView(model, this.view);

The first argument is the ViewModel instance and the second a callback (Or observable) that the boostrapper calls when the template(s) for the view is loaded. If the ViewModel sent to loadView is named CustomerViewModel then all views belonging to a root called Customer will be loaded

The file system on server could look like this. Please see the WebAPI Demo to see how a service can be implemented

  • Views
  • Customer
    • CustomerView.html
    • ProjectFeeCalculatorView.html
  • Shared
    • MasterView.html
    • DatePickerView.html

Source

https://github.com/AndersMalmgren/Knockout.Bootstrap

Clone this wiki locally