diff --git a/select2-latest.html b/select2-latest.html index 4d8678f7..072deaa7 100755 --- a/select2-latest.html +++ b/select2-latest.html @@ -454,6 +454,22 @@ $("#e2_2").select2({
+ You can set data-
attributes to <option>
(or <optgroup>) and use them inside temptlating functions:
+
+ <select> + <option value="0" data-foo="bar">option one</option> + ... + </select> ++
+ function format(state) { + var originalOption = state.element; + + return "<img class='flag' src='images/flags/" + state.id.toLowerCase() + ".png' alt='" + originalOption.data('foo') + "' />" + state.text; + } +
text
property that is returned.
+ <option>
(or <optgroup>) element is accessible inside the specified function through the property item.element
:
+ + format(item) { + var originalOption = item.element; + // return item.text + } +
text
property that is returned.
+ <option>
(or <optgroup>) element is accessible inside the specified function through the property item.element
:
+ + format(item) { + var originalOption = item.element; + // return item.text + } +