4
votes

I just noticed that using the throttle extender causes Knockout Validation to stop working. Is there a way around this problem?

var viewModel = {
    label1: ko.observable('label1').extend({required: true}),
    label2: ko.observable('label2').extend({required: true, throttle: 1}),
};

ko.applyBindings(viewModel);

jsFiddle: http://jsfiddle.net/rWqkC/

2

2 Answers

7
votes

In this case the order of the extenders does matter because the throttle extender return a new ko.dependentObservable that's why if you have the required first then it will apply on the wrong observable.

Change the order and it should work:

ko.observable('label2').extend({throttle: 500, required: true }),

But because the extender execution in the order of the property declaration isn't really defined you are safer if you use use two extends in this case:

ko.observable('label2').extend({throttle: 500}).extend({required: true })

Demo fiddle.

0
votes

For anyone who finds this answer:

If you're using a Knockout version after 3.1.0, consider using the rateLimit extender. (rateLimit instead of throttle)