I have a small app filtering a list of items by providing several choices for different attributes in combobox (select) elements. Everything works fine selecting and deselecting single combobox elements, but since I introduced a required button to "Reset Filter settings" which resets all combobox elements to null I get poor performance. It seems that each single statement modifying a comboxbox is triggering a refresh of the complete list.
How can I tell knockout to STOP updating the observables, have all combobox elements reset to null and then tell knockout to RESUME updating or initially TRIGGER the update myself.
Any ideas?
Thanks Andreas
You could pause the computed property(or properties) managing the list while you reset all your combos.
See http://www.knockmeout.net/2011/04/pausing-notifications-in-knockoutjs.html
Shamelessly expanding on Niko's comment, you should use the throttle extender.
Adding .extend({ throttle: 10 })
to my computed declaration fixed this problem for me:
// get only selected markets
self.SelectedMarkets = ko.computed(function() {
return ko.utils.arrayFilter(self.Markets(), function(market) {
return market.IsSelected() == 1; });
}).extend({ throttle: 10 });
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