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,
|
min: 1,
|
||||||
selectable: false,
|
selectable: false,
|
||||||
size: 'medium',
|
size: 'medium',
|
||||||
style: '',
|
style: 'default',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
value: options.max != 1 ? [] : ''
|
value: options.max != 1 ? [] : ''
|
||||||
})
|
})
|
||||||
|
@ -88,7 +88,8 @@ Ox.ButtonGroup = function(options, self) {
|
||||||
});
|
});
|
||||||
self.options.value = self.optionGroup.value();
|
self.options.value = self.optionGroup.value();
|
||||||
that.triggerEvent('change', {
|
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
|
? Ox.getObjectById(self.options.buttons, self.options.value).title
|
||||||
: self.options.value.map(function(value) {
|
: self.options.value.map(function(value) {
|
||||||
return Ox.getObjectById(self.options.buttons, value).title;
|
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);
|
var position = Ox.getIndexById(self.options.buttons, value);
|
||||||
if (position > -1) {
|
if (position > -1) {
|
||||||
self.$buttons[position].trigger('click');
|
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;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue