Commit 9cccf38a authored by Piotr Romanowski's avatar Piotr Romanowski

Added ability to add css class to data provider options.

You can now add a class option to a node of the data provider options and it will be appended to the list item.
parent 6367ced0
...@@ -252,6 +252,11 @@ ...@@ -252,6 +252,11 @@
optionLabel: function(element){ optionLabel: function(element){
return $(element).attr('label') || $(element).text(); return $(element).attr('label') || $(element).text();
}, },
optionClass: function(element) {
return $(element).attr('class') || '';
},
/** /**
* Triggered on change of the multiselect. * Triggered on change of the multiselect.
* *
...@@ -675,12 +680,14 @@ ...@@ -675,12 +680,14 @@
// Support the label attribute on options. // Support the label attribute on options.
var label = this.options.optionLabel(element); var label = this.options.optionLabel(element);
var classes = this.options.optionClass(element);
var value = $element.val(); var value = $element.val();
var inputType = this.options.multiple ? "checkbox" : "radio"; var inputType = this.options.multiple ? "checkbox" : "radio";
var $li = $(this.options.templates.li); var $li = $(this.options.templates.li);
var $label = $('label', $li); var $label = $('label', $li);
$label.addClass(inputType); $label.addClass(inputType);
$li.addClass(classes);
if (this.options.enableHTML) { if (this.options.enableHTML) {
$label.html(" " + label); $label.html(" " + label);
...@@ -1220,6 +1227,7 @@ ...@@ -1220,6 +1227,7 @@
value: option.value, value: option.value,
label: option.label || option.value, label: option.label || option.value,
title: option.title, title: option.title,
class: option.class,
selected: !!option.selected, selected: !!option.selected,
disabled: !!option.disabled disabled: !!option.disabled
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment