knockout-extensions

How to remove extender from an existing observable?

允我心安 提交于 2019-12-21 03:18:08
问题 I am using the Knockout Validation plugin and setting an observable as required using the extender: myObservable.extend({required:true}); Is it possible for me to remove the extender after adding it? 回答1: You can remove all the validation relates properties form an observable which were added by the ko validation with calling: myObservable.extend({validatable: false}); Or if you want to only remove the required validation you can remove it from the rules collection: myObservable.rules.remove

How to remove extender from an existing observable?

本小妞迷上赌 提交于 2019-12-03 09:53:26
I am using the Knockout Validation plugin and setting an observable as required using the extender: myObservable.extend({required:true}); Is it possible for me to remove the extender after adding it? You can remove all the validation relates properties form an observable which were added by the ko validation with calling: myObservable.extend({validatable: false}); Or if you want to only remove the required validation you can remove it from the rules collection: myObservable.rules.remove(function (item) { return item.rule == "required"; }); } Demo JSFiddle . But the ko validation has support