I'd like to make the following inputs visible only if the database
property is selected (on Bootstrap change event). Is there an elegant and effective solution in Knockout JS to do it inside HTML and if not then what would be the JavaScript way?
<select id="db" class="form-control" data-bind="value: database, valueUpdate: 'change'">
<option disabled selected> -- select an option -- </option>
<option>MySQL database format</option>
<option>PostgreSQL database format</option>
<option>Other format</option>
</select>
<label>Address :</label>
<input type="text" class="form-control" id="address" data-bind="visible: database">
<label>Port :</label>
<input type="text" class="form-control" id="port">
I'm thinking about using something like data-bind="visible: typeof database != 'undefined'"
, but such expressions with trying to access database
throw Uncaught ReferenceError: database is not defined
. Approach with jQuery doesn't work either.