update tab panel and button group so that selected can be set from outside

This commit is contained in:
rlx 2011-11-06 14:08:13 +00:00
parent e7c36dacc8
commit 7e2e0cedb6
2 changed files with 19 additions and 5 deletions

View file

@ -75,5 +75,15 @@ Ox.ButtonGroup = function(options, self) {
}
}
that.select = function(id) {
// fixme: this doesn't work in cases where
// multiple buttons can be selected
var position = Ox.getPositionById(self.options.buttons, id);
if (position > -1) {
self.$buttons[position].trigger('click');
}
};
return that;
};

View file

@ -20,12 +20,10 @@ Ox.TabPanel = function(options, self) {
selectable: true,
})
.bindEvent({
change: function(event) {
self.selected = event.selected[0];
change: function(data) {
self.selected = data.selected[0];
that.$element.replaceElement(1, self.options.content(self.selected));
that.triggerEvent('change', {
selected: self.selected
});
that.triggerEvent('change', {selected: self.selected});
}
})
.appendTo(self.$bar);
@ -50,6 +48,12 @@ Ox.TabPanel = function(options, self) {
})[0].id;
}
that.select = function(id) {
if (Ox.getPositionById(self.options.tabs, id) > -1) {
self.$tabs.select(id);
}
};
that.selected = function() {
return self.selected;
};