in TabPanel, make sure content can be array or function

This commit is contained in:
rolux 2011-11-30 15:37:02 +01:00
parent 14aafa5487
commit 5dc9b1e45b

View file

@ -22,7 +22,7 @@ Ox.TabPanel = function(options, self) {
.bindEvent({
change: function(data) {
self.selected = data.selected[0];
that.$element.replaceElement(1, self.options.content(self.selected));
that.$element.replaceElement(1, getContent());
that.triggerEvent('change', {selected: self.selected});
}
})
@ -35,13 +35,19 @@ Ox.TabPanel = function(options, self) {
size: 24
},
{
element: self.options.content(self.selected)
element: getContent()
}
],
orientation: 'vertical'
})
.addClass('OxTabPanel');
function getContent() {
return Ox.isObject(self.options.content)
? self.options.content[self.selected]
: self.options.content(self.selected);
}
function getSelected() {
return self.options.tabs.filter(function(tab) {
return tab.selected;