summaryrefslogtreecommitdiffstats
path: root/jquery.multiple.select.js
diff options
context:
space:
mode:
authorzhixin <wenzhixin2010@gmail.com>2015-11-24 15:55:02 +0800
committerzhixin <wenzhixin2010@gmail.com>2015-11-24 15:55:02 +0800
commit29d988c60d2be26b1882c3148046459cdaac2574 (patch)
tree20a50f2f83b101fd9db20fd0311ee0a87f6dfe95 /jquery.multiple.select.js
parentee272906d86d8a4e4e4c5209a46dba58b12bb677 (diff)
downloadmultiple-select-29d988c60d2be26b1882c3148046459cdaac2574.zip
multiple-select-29d988c60d2be26b1882c3148046459cdaac2574.tar.gz
multiple-select-29d988c60d2be26b1882c3148046459cdaac2574.tar.bz2
Fix #184: prevented the dropdown handle error.
Diffstat (limited to 'jquery.multiple.select.js')
-rw-r--r--jquery.multiple.select.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/jquery.multiple.select.js b/jquery.multiple.select.js
index ee81828..57a4e99 100644
--- a/jquery.multiple.select.js
+++ b/jquery.multiple.select.js
@@ -28,7 +28,8 @@
};
function MultipleSelect($el, options) {
- var name = $el.attr('name') || options.name || '';
+ var that = this,
+ name = $el.attr('name') || options.name || '';
this.options = options;
@@ -72,6 +73,20 @@
this.selectAllName = 'data-name="selectAll' + name + '"';
this.selectGroupName = 'data-name="selectGroup' + name + '"';
this.selectItemName = 'data-name="selectItem' + name + '"';
+
+ if (!this.options.keepOpen) {
+ $('body').click(function (e) {
+ if ($(e.target)[0] === that.$choice[0] ||
+ $(e.target).parents('.ms-choice')[0] === that.$choice[0]) {
+ return;
+ }
+ if (($(e.target)[0] === that.$drop[0] ||
+ $(e.target).parents('.ms-drop')[0] !== that.$drop[0] && e.target !== $el[0]) &&
+ that.options.isOpen) {
+ that.close();
+ }
+ });
+ }
}
MultipleSelect.prototype = {
@@ -125,20 +140,6 @@
if (this.options.isOpen) {
this.open();
}
-
- if (!this.options.keepOpen) {
- $('body').click(function (e) {
- if ($(e.target)[0] === that.$choice[0] ||
- $(e.target).parents('.ms-choice')[0] === that.$choice[0]) {
- return;
- }
- if (($(e.target)[0] === that.$drop[0] ||
- $(e.target).parents('.ms-drop')[0] !== that.$drop[0]) &&
- that.options.isOpen) {
- that.close();
- }
- });
- }
},
optionToHtml: function (i, elm, group, groupDisabled) {