From 8a447b8640b7620836457623bc04057a5246dbcd Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 6 Apr 2012 20:52:40 +0200 Subject: [PATCH] fix a bug that would make it impossible to progamatically deselect a button in a button group --- source/Ox.UI/js/Form/Ox.ButtonGroup.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.ButtonGroup.js b/source/Ox.UI/js/Form/Ox.ButtonGroup.js index 6ebaf3c7..65ad8568 100644 --- a/source/Ox.UI/js/Form/Ox.ButtonGroup.js +++ b/source/Ox.UI/js/Form/Ox.ButtonGroup.js @@ -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; };