この
ViewModelには次の構築を使用できます
var viewModel = new function()
{
var self = this;
self.items = ko.observableArray(); // your items
self.waitingResponse = ok.observable(false); // true - when you are waiting for response
self.sendRequest = function()
{
self.waitingResponse(true); // this will hide table with items
// and disaplay "Waiting for response..."
$.ajax(
{
//
complete: function()
{
self.waitingResponse(false); // this will display table with items
// and hide "Waiting for response..."
}
})
}
}
意見
<div data-bind="visible : waitingResponse()">
<span>Waiting for response...</span>
</div>
<div data-bind="visible : !waitingResponse()">
<table>
<!-- table with items -->
</table>
</div>