You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a viewmodel with a parent/child, and the child has a property with a required rule. the required rule has an onlyIf which needs to look at a parent property.
in my parent vm I have a fooParent observable equal to true or false. This is updated in the UI via a dropdown.
in my child vm fooChild I need to set the onlyIf required part based on the fooParent observable.
it all works great for small data sets, but large datasets the UI will freeze when the dropdown is changed.
Is there a way to add a required onlyIf to a child property without it freezing or locking up the UI as it builds the validation rules for each child?
Could I add the rules to the children from the parent vm or would I run into an issue with any new children that are added later through the UI not having the rule applied.
==
pseudo code.. typing from my head to try and provide a small example. this in the real world the child array would be mapped to the array coming in. the key thing is the onlyIf: in the fooChild rule.
var parentvm = function() {
var self = this;
self.fooParent = ko.observable(false);
//there will be 200+ children mapped here.
self.Children = ko.observableArray( [ new childvm(self) ]);
}
var childvm = function(parent) {
var self = this;
var fooChild = ko.observable().extend({ required: { ... onlyIf: function() { return parent.fooParent() } } })
}
The text was updated successfully, but these errors were encountered:
I have a viewmodel with a parent/child, and the child has a property with a required rule. the required rule has an onlyIf which needs to look at a parent property.
in my parent vm I have a fooParent observable equal to true or false. This is updated in the UI via a dropdown.
in my child vm fooChild I need to set the onlyIf required part based on the fooParent observable.
it all works great for small data sets, but large datasets the UI will freeze when the dropdown is changed.
Is there a way to add a required onlyIf to a child property without it freezing or locking up the UI as it builds the validation rules for each child?
Could I add the rules to the children from the parent vm or would I run into an issue with any new children that are added later through the UI not having the rule applied.
==
pseudo code.. typing from my head to try and provide a small example. this in the real world the child array would be mapped to the array coming in. the key thing is the onlyIf: in the fooChild rule.
The text was updated successfully, but these errors were encountered: