forked from 0x2620/oxjs
form elements rewrite, part 2
This commit is contained in:
parent
fe303bf2b0
commit
074902d079
33 changed files with 163 additions and 153 deletions
|
|
@ -49,6 +49,7 @@ Ox.CheckboxGroup = function(options, self) {
|
|||
'checked'
|
||||
);
|
||||
self.options.checkboxes = self.optionGroup.init();
|
||||
self.options.value = self.optionGroup.value();
|
||||
|
||||
self.$checkboxes = [];
|
||||
if (self.options.type == 'group') {
|
||||
|
|
@ -78,18 +79,19 @@ Ox.CheckboxGroup = function(options, self) {
|
|||
var toggled = self.optionGroup.toggle(pos);
|
||||
Ox.Log('Form', 'change', pos, 'toggled', toggled)
|
||||
if (!toggled.length) {
|
||||
self.$checkboxes[pos].options({
|
||||
value: !self.$checkboxes[pos].options('value')
|
||||
});
|
||||
// FIXME: fix and use that.toggleOption()
|
||||
self.$checkboxes[pos].value(!self.$checkboxes[pos].value());
|
||||
} else {
|
||||
toggled.forEach(function(i) {
|
||||
i != pos && self.$checkboxes[i].options({
|
||||
// FIXME: fix and use that.toggleOption()
|
||||
value: !self.$checkboxes[i].options('value')
|
||||
});
|
||||
i != pos && self.$checkboxes[i].value(!self.$checkboxes[i].value());
|
||||
});
|
||||
self.options.value = self.optionGroup.value();
|
||||
that.triggerEvent('change', {
|
||||
title: Ox.isString(self.options.value)
|
||||
? Ox.getObjectById(self.options.checkboxes, self.options.value).title
|
||||
: self.options.value.map(function(value) {
|
||||
return Ox.getObjectById(self.options.checkboxes, value).title;
|
||||
}),
|
||||
value: self.options.value
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue