Adsense
Popular Posts
- MySQL workbench -"Could not decrypt password cache"
- peer review (3)
- PHP, dump varailbes in a format way
- "Unusual traffic from your computer network" from blogger
- Install APXS in Redhat Linux
- JavaScript, remove trailing insignificant zeros after toFixed function
- Update member directory
- Set Windows path command line
- JavaScript: add days to current date
- DataTable table order by numeric, not by text
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