summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhixin <wenzhixin2010@gmail.com>2014-03-12 09:33:27 +0800
committerzhixin <wenzhixin2010@gmail.com>2014-03-12 09:33:27 +0800
commit486f6055078749623786bbf5fbd3a83676077dbc (patch)
tree9072b211b957d93f292e3acbe7dc7f06c68e9766
parentb04933f3e9de35f14821a3d70e1c308d9df8a69a (diff)
downloadmultiple-select-486f6055078749623786bbf5fbd3a83676077dbc.zip
multiple-select-486f6055078749623786bbf5fbd3a83676077dbc.tar.gz
multiple-select-486f6055078749623786bbf5fbd3a83676077dbc.tar.bz2
Fix #47: add 'No matches found' message when there are no results found.
-rw-r--r--jquery.multiple.select.js11
-rw-r--r--multiple-select.css4
2 files changed, 15 insertions, 0 deletions
diff --git a/jquery.multiple.select.js b/jquery.multiple.select.js
index 91fae5b..75980a7 100644
--- a/jquery.multiple.select.js
+++ b/jquery.multiple.select.js
@@ -76,6 +76,7 @@
$.each(this.$el.children(), function(i, elm) {
html.push(that.optionToHtml(i, elm));
});
+ html.push('<li class="ms-no-results">No matches found</li>');
html.push('</ul>');
this.$drop.html(html.join(''));
this.$drop.find('ul').css('max-height', this.options.maxHeight + 'px');
@@ -86,6 +87,7 @@
this.$selectGroups = this.$drop.find('input[name="selectGroup"]');
this.$selectItems = this.$drop.find('input[name="selectItem"]:enabled');
this.$disableItems = this.$drop.find('input[name="selectItem"]:disabled');
+ this.$noResults = this.$drop.find('.ms-no-results');
this.events();
this.update();
},
@@ -348,6 +350,15 @@
$items = that.$selectItems.filter(':visible');
$parent[$items.filter('[data-group="' + group + '"]').length === 0 ? 'hide' : 'show']();
});
+
+ //Check if no matches found
+ if (this.$selectItems.filter(':visible').length) {
+ this.$selectAll.parent().show();
+ this.$noResults.hide();
+ } else {
+ this.$selectAll.parent().hide();
+ this.$noResults.show();
+ }
}
this.updateOptGroupSelect();
this.updateSelectAll();
diff --git a/multiple-select.css b/multiple-select.css
index 8b8c84e..d824e0c 100644
--- a/multiple-select.css
+++ b/multiple-select.css
@@ -177,3 +177,7 @@
.ms-drop input[type="checkbox"] {
vertical-align: middle;
}
+
+.ms-drop .ms-no-results {
+ display: none;
+} \ No newline at end of file