Commit ccf0758b authored by David Stutz's avatar David Stutz

Merge pull request #604 from piotrromanowski/master

Added the ability to add class to customize class of li.
parents 8ec7d721 017cd9b2
...@@ -252,6 +252,15 @@ ...@@ -252,6 +252,15 @@
optionLabel: function(element){ optionLabel: function(element){
return $(element).attr('label') || $(element).text(); return $(element).attr('label') || $(element).text();
}, },
/**
* Create a class.
*
* @param {jQuery} element
* @returns {String}
*/
optionClass: function(element) {
return $(element).attr('class') || '';
},
/** /**
* Triggered on change of the multiselect. * Triggered on change of the multiselect.
* *
...@@ -675,12 +684,14 @@ ...@@ -675,12 +684,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);
...@@ -1227,6 +1238,7 @@ ...@@ -1227,6 +1238,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