|
152 | 152 | </style> |
153 | 153 |
|
154 | 154 | <script> |
155 | | -require(["select2/core", "select2/utils", "select2/selection"], function (Select2, Utils, Selection) { |
| 155 | +require(["select2/core", "select2/utils", "select2/selection/single", |
| 156 | + "select2/dropdown"], function (Select2, Utils, Selection, Dropdown) { |
156 | 157 | function ClearSelection () { } |
157 | 158 |
|
158 | 159 | ClearSelection.prototype.render = function (decorated) { |
|
203 | 204 | } |
204 | 205 | }; |
205 | 206 |
|
206 | | - var CustomSelection = Utils.Decorate(Selection, ClearSelection); |
| 207 | + function DropdownFooter () { } |
| 208 | + |
| 209 | + DropdownFooter.prototype.render = function (decorated) { |
| 210 | + var $dropdown = decorated.call(this); |
| 211 | + |
| 212 | + $dropdown.append('<div class="footer">My custom footer</div>'); |
| 213 | + |
| 214 | + return $dropdown; |
| 215 | + } |
| 216 | + |
| 217 | + function DropdownHeader () { } |
| 218 | + |
| 219 | + DropdownHeader.prototype.render = function (decorated) { |
| 220 | + var $dropdown = decorated.call(this); |
| 221 | + |
| 222 | + $dropdown.prepend('<div class="header">Some custom header</div>'); |
| 223 | + |
| 224 | + return $dropdown; |
| 225 | + } |
| 226 | + |
| 227 | + var CustomSelection = Utils.Decorate(Selection, ClearSelection) |
| 228 | + |
| 229 | + var CustomDropdown = Utils.Decorate( |
| 230 | + Utils.Decorate(Dropdown, DropdownHeader), |
| 231 | + DropdownFooter |
| 232 | + ); |
207 | 233 |
|
208 | 234 | var s2 = new Select2($("#source"), { |
209 | | - selectionAdapter: CustomSelection |
| 235 | + selectionAdapter: CustomSelection, |
| 236 | + dropdownAdapter: CustomDropdown |
210 | 237 | }); |
211 | 238 | }); |
212 | 239 | </script> |
|
0 commit comments