fix a bug that would make it impossible to progamatically deselect a button in a button group
This commit is contained in:
parent
e9f6751748
commit
8a447b8640
1 changed files with 9 additions and 3 deletions
|
@ -25,7 +25,7 @@ Ox.ButtonGroup = function(options, self) {
|
|||
min: 1,
|
||||
selectable: false,
|
||||
size: 'medium',
|
||||
style: '',
|
||||
style: 'default',
|
||||
type: 'text',
|
||||
value: options.max != 1 ? [] : ''
|
||||
})
|
||||
|
@ -88,7 +88,8 @@ Ox.ButtonGroup = function(options, self) {
|
|||
});
|
||||
self.options.value = self.optionGroup.value();
|
||||
that.triggerEvent('change', {
|
||||
title: Ox.isString(self.options.value)
|
||||
title: self.options.value === '' ? ''
|
||||
: Ox.isString(self.options.value)
|
||||
? Ox.getObjectById(self.options.buttons, self.options.value).title
|
||||
: self.options.value.map(function(value) {
|
||||
return Ox.getObjectById(self.options.buttons, value).title;
|
||||
|
@ -105,9 +106,14 @@ Ox.ButtonGroup = function(options, self) {
|
|||
var position = Ox.getIndexById(self.options.buttons, value);
|
||||
if (position > -1) {
|
||||
self.$buttons[position].trigger('click');
|
||||
}
|
||||
} else if (self.options.min == 0) {
|
||||
self.$buttons.forEach(function($button, i) {
|
||||
$button.options('value') && $button.trigger('click');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue