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
Friday, July 25, 2014
select element in options with different values from text using Knockout.JS
JS library Knockout is based on MVC model:
http://knockoutjs.com/
To select element in options with different values then text using Knockout.JS,
JS side:
self.StudyLeaveValue1([{ value: 1, name: 'France' }, { value: 2, name: 'Germany' },
{ value: 3, name: 'Spain' }];
HTML side:
<select data-bind="options: StudyLeaveValue1,optionsText: 'name', optionsValue: 'value',optionsCaption: 'Please choose an option'"></select>
Source code of above from inspector:
<select data-bind="options: StudyLeaveValue1,optionsText: 'name', optionsValue: 'value',optionsCaption: 'Please choose an option'">
<option value="">Please choose an option</option>
<option value="1">France</option>
<option value="2">Germany</option>
<option value="3">Spain</option>
</select>
Labels:
Knockout.JS,
MVC
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment