summaryrefslogtreecommitdiffstats
path: root/jquery.multiple.select.js
diff options
context:
space:
mode:
authorzhixin <wenzhixin2010@gmail.com>2013-05-21 09:20:54 +0800
committerzhixin <wenzhixin2010@gmail.com>2013-05-21 09:20:54 +0800
commit698b51a9ad9b441f986c9a3927c2daa960ba8d42 (patch)
treec22013268ba8c7f31c6a2e87a0f3b3afdb3f2199 /jquery.multiple.select.js
parente0300de9386c4c6983ddfdf7c153cdf195f1b695 (diff)
downloadmultiple-select-698b51a9ad9b441f986c9a3927c2daa960ba8d42.zip
multiple-select-698b51a9ad9b441f986c9a3927c2daa960ba8d42.tar.gz
multiple-select-698b51a9ad9b441f986c9a3927c2daa960ba8d42.tar.bz2
fix #2: use prop method instead of attr
Diffstat (limited to 'jquery.multiple.select.js')
-rw-r--r--jquery.multiple.select.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/jquery.multiple.select.js b/jquery.multiple.select.js
index 3b93396..db98692 100644
--- a/jquery.multiple.select.js
+++ b/jquery.multiple.select.js
@@ -20,7 +20,7 @@
this.$parent.append(this.$choice);
this.$parent.append(this.$drop);
- if (this.$el.attr('disabled')) {
+ if (this.$el.prop('disabled')) {
this.$choice.addClass('disabled');
}
this.$choice.css('width', $el.width() + 'px')
@@ -62,7 +62,7 @@
);
}
this.$el.find('option').each(function() {
- var value = $(this).attr('value'),
+ var value = $(this).prop('value'),
text = $(this).text();
html.push(
'<li' + (multiple ? ' class="multiple"' : '') + '>',
@@ -81,14 +81,12 @@
events: function() {
var that = this;
- this.$choice.off('click').click(function() {
- that[that.isopen ? 'close' : 'open']();
+ this.$choice.on('click', function() {
+ that[that.options.isopen ? 'close' : 'open']();
});
- this.$drop.find('input[name="selectAll"]').off('click').click(function() {
- var checked = $(this).attr('checked') ? true : false;
- that.$drop.find('input[name="selectItem"]').attr('checked', checked);
+ this.$drop.find('input[name="selectAll"]').on('click', function() {
+ that.$drop.find('input[name="selectItem"]').prop('checked', $(this).prop('checked'));
});
-
this.$drop.find('ul').on('click', 'input', function() {
that.update();
});
@@ -98,13 +96,13 @@
if (this.$choice.hasClass('disabled')) {
return;
}
- this.isopen = true;
+ this.options.isopen = true;
this.$choice.find('>div').addClass('open');
this.$drop.show();
},
close: function() {
- this.isopen = false;
+ this.options.isopen = false;
this.$choice.find('>div').removeClass('open');
this.$drop.hide();
this.update();
@@ -125,11 +123,11 @@
setSelects: function(values) {
var that = this;
- this.$drop.find('input[name="selectItem"]').attr('checked', false);
+ this.$drop.find('input[name="selectItem"]').prop('checked', false);
$.each(values, function(i, value) {
that.$drop
.find('input[name="selectItem"][value="' + value + '"]')
- .attr('checked', true);
+ .prop('checked', true);
});
},