Show progress bar while knockout is rendering the view
http://stackoverflow.com/questions/8227704/show-progress-bar-while-knockout-is-rendering-the-view
HTML
<script src="https://raw.github.com/SteveSanderson/knockout/master/build/output/knockout-latest.js"></script>
<input id="orderQuantity" type="text" data-bind="value:order.quantity" />
<input id="orderPrice" type="text" data-bind="value:order.price" />
<select id="orderType" data-bind="options:orderTypes">
JavaScript
var viewModel = {
order: null,
orderTypes: ko.observableArray(['Priority', 'Express', 'Normal']),
init: function(o) {
// Determine if we're working with an existing order, or a new one.
if (o == null) {
this.order = (null);
}
else {
this.order = (new order(o));
}
}
};
$().ready(function() {
newOrderData = {
id: 12,
quantity: 3,
price: 2.34,
ordertype: 'Priority'
};
viewModel.init(newOrderData);
ko.applyBindings(viewModel);
});
// The following is defined in a seperate .js file.
// I've verified its getting called by using an 'alert'
var order = function(o) {
return {
id: ko.observable(o.id),
quantity: ko.observable(o.quantity),
price: ko.observable(o.price),
orderType: ko.observable(o.orderType)
}
};