Debian Codegraph @

examples/optgroups.html

raw
1 <!DOCTYPE html>
2 <!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]-->
3 <!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]-->
4 <!--[if IE 8]><html class="no-js lt-ie9"><![endif]-->
5 <!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
6 <head>
7 <meta charset="utf-8">
8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9 <title>Selectize.js Demo</title>
10 <meta name="description" content="">
11 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
12 <link rel="stylesheet" href="css/normalize.css">
13 <link rel="stylesheet" href="css/stylesheet.css">
14 <!--[if IE 8]><script src="js/es5.js"></script><![endif]-->
15 <script src="js/jquery.min.js"></script>
16 <script src="../dist/js/standalone/selectize.js"></script>
17 <script src="js/index.js"></script>
18 <style type="text/css">
19 .demo-animals .scientific {
20 font-weight: normal;
21 opacity: 0.3;
22 margin: 0 0 0 2px;
23 }
24 .demo-animals .scientific::before {
25 content: '(';
26 }
27 .demo-animals .scientific::after {
28 content: ')';
29 }
30 </style>
31 </head>
32 <body>
33 <div id="wrapper">
34 <h1>Selectize.js</h1>
35
36 <div class="demo">
37 <h2>Optgroups (basic)</h2>
38 <div class="control-group">
39 <label for="select-gear">Gear:</label>
40 <select id="select-gear" class="demo-default" multiple placeholder="Select gear...">
41 <option value="">Select gear...</option>
42 <optgroup label="Climbing">
43 <option value="pitons">Pitons</option>
44 <option value="cams">Cams</option>
45 <option value="nuts">Nuts</option>
46 <option value="bolts">Bolts</option>
47 <option value="stoppers">Stoppers</option>
48 <option value="sling">Sling</option>
49 </optgroup>
50 <optgroup label="Skiing">
51 <option value="skis">Skis</option>
52 <option value="skins">Skins</option>
53 <option value="poles">Poles</option>
54 </optgroup>
55 </select>
56 </div>
57 <script>
58 $('#select-gear').selectize({
59 sortField: 'text'
60 });
61 </script>
62 </div>
63
64 <div class="demo">
65 <h2>Optgroups (disabled)</h2>
66 <div class="control-group">
67 <label for="select-gear-disabled">Gear:</label>
68 <select id="select-gear-disabled" class="demo-default" multiple placeholder="Select gear...">
69 <option value="">Select gear...</option>
70 <optgroup label="Climbing">
71 <option value="pitons">Pitons</option>
72 <option value="cams">Cams</option>
73 <option value="nuts">Nuts</option>
74 <option value="bolts">Bolts</option>
75 <option value="stoppers">Stoppers</option>
76 <option value="sling">Sling</option>
77 </optgroup>
78 <optgroup label="Skiing" disabled>
79 <option value="skis">Skis</option>
80 <option value="skins">Skins</option>
81 <option value="poles">Poles</option>
82 </optgroup>
83 </select>
84 </div>
85 <script>
86 $('#select-gear-disabled').selectize({
87 sortField: 'text'
88 });
89 </script>
90 </div>
91
92 <div class="demo">
93 <h2>Optgroups (repeated options)</h2>
94 <div class="control-group">
95 <label for="select-repeated-options">Options:</label>
96 <select id="select-repeated-options" class="demo-default" multiple>
97 <option value="">Select...</option>
98 <optgroup label="Group 1">
99 <option value="a">Item A</option>
100 <option value="b">Item B</option>
101 </optgroup>
102 <optgroup label="Group 2">
103 <option value="a">Item A</option>
104 <option value="b">Item B</option>
105 </optgroup>
106 </select>
107 </div>
108 <script>
109 $('#select-repeated-options').selectize({
110 sortField: 'text'
111 });
112 </script>
113 </div>
114
115 <div class="demo">
116 <h2>Optgroups (programmatic)</h2>
117 <div class="control-group">
118 <label for="select-animal">Animal:</label>
119 <select id="select-animal" class="demo-animals" placeholder="Select animal..."></select>
120 </div>
121 <script>
122 $('#select-animal').selectize({
123 options: [
124 {class: 'mammal', value: "dog", name: "Dog" },
125 {class: 'mammal', value: "cat", name: "Cat" },
126 {class: 'mammal', value: "horse", name: "Horse" },
127 {class: 'mammal', value: "kangaroo", name: "Kangaroo" },
128 {class: 'bird', value: 'duck', name: 'Duck'},
129 {class: 'bird', value: 'chicken', name: 'Chicken'},
130 {class: 'bird', value: 'ostrich', name: 'Ostrich'},
131 {class: 'bird', value: 'seagull', name: 'Seagull'},
132 {class: 'reptile', value: 'snake', name: 'Snake'},
133 {class: 'reptile', value: 'lizard', name: 'Lizard'},
134 {class: 'reptile', value: 'alligator', name: 'Alligator'},
135 {class: 'reptile', value: 'turtle', name: 'Turtle'}
136 ],
137 optgroups: [
138 {value: 'mammal', label: 'Mammal', label_scientific: 'Mammalia'},
139 {value: 'bird', label: 'Bird', label_scientific: 'Aves'},
140 {value: 'reptile', label: 'Reptile', label_scientific: 'Reptilia'}
141 ],
142 optgroupField: 'class',
143 labelField: 'name',
144 searchField: ['name'],
145 render: {
146 optgroup_header: function(data, escape) {
147 return '<div class="optgroup-header">' + escape(data.label) + ' <span class="scientific">' + escape(data.label_scientific) + '</span></div>';
148 }
149 }
150 });
151 </script>
152 </div>
153
154 <div class="demo">
155 <h2>Plugin: "optgroup_columns"</h2>
156 <div class="control-group" id="select-car-group">
157 <input type="text" id="select-car" placeholder="Select cars...">
158 </div>
159 <script>
160 $("#select-car").selectize({
161 options: [
162 {id: 'avenger', make: 'dodge', model: 'Avenger'},
163 {id: 'caliber', make: 'dodge', model: 'Caliber'},
164 {id: 'caravan-grand-passenger', make: 'dodge', model: 'Caravan Grand Passenger'},
165 {id: 'challenger', make: 'dodge', model: 'Challenger'},
166 {id: 'ram-1500', make: 'dodge', model: 'Ram 1500'},
167 {id: 'viper', make: 'dodge', model: 'Viper'},
168 {id: 'a3', make: 'audi', model: 'A3'},
169 {id: 'a6', make: 'audi', model: 'A6'},
170 {id: 'r8', make: 'audi', model: 'R8'},
171 {id: 'rs-4', make: 'audi', model: 'RS 4'},
172 {id: 's4', make: 'audi', model: 'S4'},
173 {id: 's8', make: 'audi', model: 'S8'},
174 {id: 'tt', make: 'audi', model: 'TT'},
175 {id: 'avalanche', make: 'chevrolet', model: 'Avalanche'},
176 {id: 'aveo', make: 'chevrolet', model: 'Aveo'},
177 {id: 'cobalt', make: 'chevrolet', model: 'Cobalt'},
178 {id: 'silverado', make: 'chevrolet', model: 'Silverado'},
179 {id: 'suburban', make: 'chevrolet', model: 'Suburban'},
180 {id: 'tahoe', make: 'chevrolet', model: 'Tahoe'},
181 {id: 'trail-blazer', make: 'chevrolet', model: 'TrailBlazer'},
182 ],
183 optgroups: [
184 {$order: 3, id: 'dodge', name: 'Dodge'},
185 {$order: 2, id: 'audi', name: 'Audi'},
186 {$order: 1, id: 'chevrolet', name: 'Chevrolet'}
187 ],
188 labelField: 'model',
189 valueField: 'id',
190 optgroupField: 'make',
191 optgroupLabelField: 'name',
192 optgroupValueField: 'id',
193 lockOptgroupOrder: true,
194 searchField: ['model'],
195 plugins: ['optgroup_columns'],
196 openOnFocus: false
197 });
198 </script>
199 </div>
200 </div>
201 </body>
202 </html>