Is there any option to suspend and resume bindings in knockout?
Version : knockout.js 1.2.1
Our need for suspending bindings stems from the following. During some operations we have to load a lot of data from the server, eg multiple selects have their entire data changed, there are tables whose rows are dynamically added etc.
Now in this current scenario, the form is fully bound with the view model. When we clear the combos and add each item, the view gets refreshed hence there is significant delay. If I had the means to suspend binding, I could suspend, then load all data into the viewmodel and then resume binding again.
I don't think there is a way to suspend binding in knockout.js. Without seeing the code it's hard to say, but the slowness is probably caused by the fact that you refresh you observableArrays by clearing them and adding new items one by one. Instead you can refresh the entire array at once:
...
self.manyItems = ko.observableArray();
...
function refreshItems(newItems){
self.manyItems(newItems);
}
Suspending and resuming is possible: take a look at this demo put together by Ryan Niemeyer. Refer to this entry on his blog for more background information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With