I am getting the following error:
Microsoft JScript runtime error: Unable to parse binding attribute.
Message: TypeError: Object expected; Attribute value: visible:
IsVisible('Area')
I am trying to hide / show my html elements based on some evaluation. This is my code:
var viewModel = {
propertyTypeList: ko.observableArray([]),
selectedPropertyType: ko.observable(""),
visibleFeatures: ko.observableArray([]),
IsVisible : function(featureName){some logic here}
};
And this is the view:
<div class="editor-field">
<select data-bind="options: propertyTypeList,
optionsText: 'PropertyTypeName',
value: selectedPropertyType,
optionsCaption: 'select property type...'">
</select>
</div>
<div class="editor-label" data-bind="visible: IsVisible('Area')">
Area
</div>
<div class="editor-label" data-bind="visible: IsVisible('Bedroom')">
Bedroom
</div>
The function IsVisible
will do some evaluation based on the selectedPropertyType
and the feature name and will return true or false.