javascript - Knockout select options and dependencies -
I have a selection list and I want to change the visibility of different divs based on the selection.
& lt; Table & gt; & Lt; Tbody data-bind = "foreach: conditions" & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Select data-bind = "option: $ parent.conditionTypes, optionsText: 'name', optionsValue: 'id', value: type" & gt; & Lt; / Select & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Div data-bind = "visible: $ parent.isGroupCondition ($ data)" & gt; Group list & lt; / Div & gt; & Lt; Div data-bind = "visible: $ parent.isTagCondition ($ data)" & gt; Tag list & lt; / Div & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Select data-bind = "option: $ parent.conditionOperations, optionsText: 'name', optionsValue: 'id', value: operation" & gt; & Lt; / Select & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; Input type = "text" data-bind = "atri: {value: value}" /> & Lt; / TD & gt; & Lt; TD & gt; & Lt; A href = "#" data-bind = "click: $ parent.removeCondition.bind ($ parent)" & gt; Remove & lt; / A & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; I tried to use the event binding "Event: {parent: $ parent.conditionTypeChanged}", but I'm not sure how to bind the binding of the div .
Any help is greatly appreciated.
Edit:
You just type the type Property must be in the situations in properties: ko.observableArray ([{type: ko.observable (1), operation: 1, value: 'test Use the Viewable in your isGroupCondition and isTagCondition Functions: isGroupCondition: function (condition) {return condition.type () === 2; }, IsTagCondition: function (condition) {return condition.type () === 1; }, Because your type will now look into updating an observable knockout visibility binding and hide / show your device. Demo
Comments
Post a Comment