Show/hide Based On Dropdown Selection In Knockoutjs With Model Inside Another Model
I am working on 'Rules' for form builder. I want to show/hide text box based on the dropdown selected. For example, let us assume we have a following 'Rules' for a 'TextField' cont
Solution 1:
The problems in your code:
- The visible binding:
selectedValueis a property inTextBoxViewModel, not inRuleConditionViewModel. Therefore,visible: ruleConditions().selectedValue()should only bevisible: selectedValue - The
optionsValue: 'Value'binding tells knockout to only store theValueproperty of a rule condition. I.e.: it stores the stringisfilledoutorcontains. Remove it, and the whole object is stored. - Because the
selectedItemwas a string, the computed expressionthis.selectedItem() && this.selectedItem().isExpressionValueRequiredwas always false: thestringprototype does not have a property namedisExpressionValueRequired.
Post a Comment for "Show/hide Based On Dropdown Selection In Knockoutjs With Model Inside Another Model"