Skip to content
Anders Malmgren edited this page Jun 22, 2014 · 4 revisions

Welcome to the Knockout.Bootstrap.TemplateStore wiki!

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

ASP.NET

For Asp.Net install the template store using this command

Install-Package Knockout.Bootstrap.TemplateStore.SystemWeb

The library uses Owin to support both System.Web sites and self hosted Owin sites. For ASP.NET use this Owin Start class

[assembly: OwinStartup(typeof(TemplateStoreConfig))]
namespace Knockout.Bootstrap.Demo.Web.App_Start
{
    public static class TemplateStoreConfig
    {
        public static void Configuration(IAppBuilder app)
        {
            app.InitTemplateStore();
        }
    }
}

For self hosted apps install

Install-Package Knockout.Bootstrap.TemplateStore

Client

Install the client using

Install-Package Knockout.Bootstrap.TemplateStore.Client

The template bootstrapper is initialized like this

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

When the shared templates have been loaded the appStart function will be called. 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.

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

Demo project

Live Demo

Clone this wiki locally