Commit a393cf77 authored by Andrew Durber's avatar Andrew Durber

Added support for data attributes

parent 03582561
...@@ -1413,24 +1413,39 @@ ...@@ -1413,24 +1413,39 @@
}); });
forEach(option.children, function(subOption) { // add children option tags forEach(option.children, function(subOption) { // add children option tags
$tag.append($('<option/>').attr({ var attributes = {
value: subOption.value, value: subOption.value,
label: subOption.label || subOption.value, label: subOption.label || subOption.value,
title: subOption.title, title: subOption.title,
selected: !!subOption.selected, selected: !!subOption.selected,
disabled: !!subOption.disabled disabled: !!subOption.disabled
})); };
//Loop through attributes object and add key-value for each attribute
for (var key in subOption.attributes) {
attributes['data-' + key] = subOption.attributes[key];
}
//Append original attributes + new data attributes to option
$tag.append($('<option/>').attr(attributes));
}); });
} }
else { else {
$tag = $('<option/>').attr({
var attributes = {
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, class: option.class,
selected: !!option.selected, selected: !!option.selected,
disabled: !!option.disabled disabled: !!option.disabled
}); };
//Loop through attributes object and add key-value for each attribute
for (var key in option.attributes) {
attributes['data-' + key] = option.attributes[key];
}
//Append original attributes + new data attributes to option
$tag = $('<option/>').attr(attributes);
$tag.text(option.label || option.value); $tag.text(option.label || option.value);
} }
......
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