Binding to Bootatrap progress bar

Examples

Striped
Animated
Text hidden
Success Info Warning Danger

Html markup

<div data-bind="progress: { value: value, type: type, text: text, textHidden: textHidden, animated: animated, striped: striped }"></div>

View model

function ProgressExampleViewModel() {
    this.value = ko.observable(50);

    this.animated = ko.observable();

    this.striped = ko.observable();

    this.type = ko.observable('info');

    this.text = ko.observable('Complete');

    this.textHidden = ko.observable(true);
}

Also it is possible to use only number as model for progress binding:

Html markup

<div data-bind="progress: progress"></div>

View model

function ProgressExampleViewModel() {
    //...

    this.progress = ko.observable(20);
}

Options

All of the options can be observables.

data-bind="progress: { value: value, type: type, text: text, textHidden: hidden, animated: animated, striped: striped }"

Short notation

If you only need use progress value, you can use short notation of binding, which uses only number as model.

data-bind="progress: progressValue"

Default values

Default values for progress binding located in ko.bindingHandlers.progress.defaults object. It contains default css for root element of progress-bar and default values for its options. Can be changed before ko.applyBindigs() is called.

defaults: {
    css: 'progress',
    text: '',
    textHidden: true,
    striped: false,
    type: '',
    animated: false
}