Skip to content

Commit

Permalink
Fix : select2#4876 - optgroup cannot be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
DVD27 committed Apr 22, 2017
1 parent c155ca5 commit 524f0c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/js/select2/data/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,30 @@ define([
return $option;
};

SelectAdapter.prototype.item = function ($option) {
SelectAdapter.prototype.item = function ($option, disabledParent) {
var data = {};

data = $.data($option[0], 'data');

if (data != null) {
return data;
}

var disabled = disabledParent || $option.prop('disabled');

if ($option.is('option')) {
data = {
id: $option.val(),
text: $option.text(),
disabled: $option.prop('disabled'),
disabled: disabled,
selected: $option.prop('selected'),
title: $option.prop('title')
};
} else if ($option.is('optgroup')) {
data = {
text: $option.prop('label'),
children: [],
disabled: disabled,
title: $option.prop('title')
};

Expand All @@ -227,7 +230,7 @@ define([
for (var c = 0; c < $children.length; c++) {
var $child = $($children[c]);

var child = this.item($child);
var child = this.item($child, disabled);

children.push(child);
}
Expand Down

0 comments on commit 524f0c0

Please sign in to comment.