Skip to content
This repository has been archived by the owner on Jan 20, 2019. It is now read-only.

added "filter" option, to dinamically exclude given <option>s from <select> #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions jquery.simpleselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
options = $.extend({}, {
fadingDuration: (options && options.fadeSpeed) || 0,
containerMargin: 5,
displayContainerInside: "window"
displayContainerInside: "window",
filter: ".hidden"
}, options);

// Loop through all selects
Expand Down Expand Up @@ -159,7 +160,7 @@

// Populate the SimpleSelect with the select's options
populateSs = function() {
this.selectOptions = this.select.find("option");
this.selectOptions = this.select.find("option").not(this.options.filter);
var ssOptionsAndOptgroups = "",
addOption = function(selectOption) {
ssOptionsAndOptgroups += "<div class=\"option\">"+ selectOption.text() +"</div>";
Expand All @@ -178,7 +179,7 @@
htmlEncode = function(html) {
return html.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#039;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
},
selectChildren = this.select.children("optgroup, option"),
selectChildren = this.select.children("optgroup, option").not(this.options.filter),
selectHasOptgroups = false;
selectChildren.each(function() {
var t = $(this);
Expand Down Expand Up @@ -473,4 +474,4 @@
});
});

})(jQuery);
})(jQuery);