Commit 958a7e2d authored by David Stutz's avatar David Stutz

Merge pull request #160 from sathyamoorthi/select-deselect

select and deselect changed to accept array.
parents 5f12a94e e726973f
...@@ -446,7 +446,14 @@ ...@@ -446,7 +446,14 @@
}, },
// Select an option by its value. // Select an option by its value.
select: function(value) { select: function(selectValues) {
if(selectValues && !$.isArray(selectValues)) {
selectValues = [selectValues];
}
for(var i = 0; i < selectValues.length; i ++) {
var value = selectValues[i];
var $option = $('option', this.$select).filter(function() { var $option = $('option', this.$select).filter(function() {
return $(this).val() == value; return $(this).val() == value;
}); });
...@@ -461,13 +468,21 @@ ...@@ -461,13 +468,21 @@
$checkbox.prop('checked', true); $checkbox.prop('checked', true);
$option.attr('selected', 'selected').prop('selected', true); $option.attr('selected', 'selected').prop('selected', true);
this.options.onChange($option, true);
}
this.updateButtonText(); this.updateButtonText();
this.options.onChange($option, true);
}, },
// Deselect an option by its value. // Deselect an option by its value.
deselect: function(value) { deselect: function(deselectValues) {
if(deselectValues && !$.isArray(deselectValues)) {
deselectValues = [deselectValues];
}
for(var i = 0; i < deselectValues.length; i ++) {
var value = deselectValues[i];
var $option = $('option', this.$select).filter(function() { var $option = $('option', this.$select).filter(function() {
return $(this).val() == value; return $(this).val() == value;
}); });
...@@ -482,9 +497,10 @@ ...@@ -482,9 +497,10 @@
$checkbox.prop('checked', false); $checkbox.prop('checked', false);
$option.removeAttr('selected').prop('selected', false); $option.removeAttr('selected').prop('selected', false);
this.options.onChange($option, false);
}
this.updateButtonText(); this.updateButtonText();
this.options.onChange($option, false);
}, },
// Rebuild the whole dropdown menu. // Rebuild the whole dropdown menu.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment