Application:
<select data-bind="value: $data.selectedApp, options: $parent.applications, optionsText: 'ApplicationName', optionsCaption: 'Choose an Application'" style="width: 32px" name="Application list" id="dataBox">
</select>
With this I'm trying to make
<Div = "main">...</div>
visable when a dropdown called "USB Access Request" is clicked.
My javascript:
<script>
var viewModel = {
selectedChoice: ko.observable("USB Read/Write") ,
selectionChanged: function(event) {
show( "main" );
}
};
ko.applyBindings(viewModel);
</script>
You might be looking for something like this
View model:
var viewModel = function () {
var self = this;
self.selectedApp = ko.observable();
self.applications = ko.observableArray([{
"ApplicationName": "application1"},{
"ApplicationName": "application2"},{
"ApplicationName": "application3"}
]);
};
ko.applyBindings(new viewModel())
View :
Application:
<select data-bind="value:selectedApp,options:applications,optionsText:'ApplicationName',optionsCaption:'Choose an Application'" style="width: 160px"></select>
<div data-bind="if:selectedApp">
<h2>i'm Main DIV</h2>
</div>
Well i see the html is simple so its always better to use if
binding in this case .
Working fiddle here
Any issues let us know
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.