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:
selectedValue
is a property inTextBoxViewModel
, not inRuleConditionViewModel
. Therefore,visible: ruleConditions().selectedValue()
should only bevisible: selectedValue
- The
optionsValue: 'Value'
binding tells knockout to only store theValue
property of a rule condition. I.e.: it stores the stringisfilledout
orcontains
. Remove it, and the whole object is stored. - Because the
selectedItem
was a string, the computed expressionthis.selectedItem() && this.selectedItem().isExpressionValueRequired
was always false: thestring
prototype does not have a property namedisExpressionValueRequired
.
Post a Comment for "Show/hide Based On Dropdown Selection In Knockoutjs With Model Inside Another Model"