Skip to content

Commit

Permalink
fix: Max settings disabling every option
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenoo committed Jun 19, 2021
1 parent 107492d commit 8dcf535
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions jquery.sumoselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,19 +269,21 @@

_handleMax: function () {
// Disable options if max reached
if (this.selectedCount >= +settings.max) {
this.optDiv.find('li.opt').not('.hidden').each(function (ix, e) {
if (!$(e).hasClass('selected')) {
$(e).addClass('temporary-disabled disabled');
}
});
} else {
// Enable options back
this.optDiv.find('li.opt').not('.hidden').each(function (ix, e) {
if ($(e).hasClass('temporary-disabled')) {
$(e).removeClass('temporary-disabled disabled');
}
});
if(settings.max){
if (this.selectedCount >= +settings.max) {
this.optDiv.find('li.opt').not('.hidden').each(function (ix, e) {
if (!$(e).hasClass('selected')) {
$(e).addClass('temporary-disabled disabled');
}
});
} else {
// Enable options back
this.optDiv.find('li.opt').not('.hidden').each(function (ix, e) {
if ($(e).hasClass('temporary-disabled')) {
$(e).removeClass('temporary-disabled disabled');
}
});
}
}
},

Expand Down

0 comments on commit 8dcf535

Please sign in to comment.