Adsense
Popular Posts
- Code update from PHP 7.4 to PHP 8.1 - PhpSpreadsheet
- MySQL workbench -"Could not decrypt password cache"
- Code update from PHP 7.4 to PHP 8.1 - Worksheet/Iterator.php
- Rendering HTML tags inside textarea
- axios handle blob type data
- Unix Utils and wget in Windows
- increase mysql query speed
- Setup vi syntax for PHP
- Get WAMP running on EC2
- EXCEL return to the next line in the same cell
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