Adsense
Popular Posts
- jQuery autocomplete scroll bar for dropdown menu
- JavaScript Arrays and Associate Arrays
- mod_auth_cas.so error: undefined symbol: SSL_connect
- Design date and signature box in Latex
- Install APXS in Redhat Linux
- JavaScript, remove trailing insignificant zeros after toFixed function
- jQuery, toggle the display
- Difference between state and props in React
- Set Windows path command line
- super(props) in React
Saturday, July 26, 2014
Passing parameters in visible function in data-bind in knockout.js
Passing parameters in visible function in data-bind in knockout.js
HTML code:
<div class="editor-field">
<select data-bind="options: propertyTypeList, 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>
JS code:
function ViewModel() {
var self = this;
self.propertyTypeList = ko.observableArray(['Area', 'Bedroom', 'Other']);
self.selectedPropertyType = ko.observable("");
self.visibleFeatures = ko.observableArray([]);
self.isVisible = function (type) {
//Your logic here
return self.selectedPropertyType() === type;
};
};
ko.applyBindings(new ViewModel());
Labels:
Knockout.JS
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment