in Ox.List, handle Ox.TreeList items update

This commit is contained in:
rolux 2012-06-17 19:13:18 +02:00
parent ad368fb819
commit fe8c97db24

View file

@ -70,6 +70,9 @@ Ox.List = function(options, self) {
.options(options || {}) .options(options || {})
.update({ .update({
items: function() { items: function() {
if (!self.isAsync) {
updateItems();
} else {
if (Ox.isArray(self.options.items)) { if (Ox.isArray(self.options.items)) {
self.options.items = Ox.api(self.options.items, { self.options.items = Ox.api(self.options.items, {
cache: true, cache: true,
@ -84,6 +87,7 @@ Ox.List = function(options, self) {
*/ */
} }
updateQuery(); updateQuery();
}
}, },
selected: function() { selected: function() {
var previousSelected = self.selected; var previousSelected = self.selected;
@ -239,20 +243,8 @@ Ox.List = function(options, self) {
]; ];
} }
if (!self.isAsync) { !self.isAsync ? updateItems() : updateQuery();
self.$pages = [];
self.$pages[0] = Ox.Element()
.addClass('OxPage')
.css({
left: self.listMargin / 2 + 'px',
top: self.listMargin / 2 + 'px'
})
.appendTo(that.$content);
self.listLength = self.options.items.length;
loadItems();
} else {
updateQuery();
}
that.bindEvent(self.keyboardEvents); that.bindEvent(self.keyboardEvents);
//Ox.UI.$window.resize(that.size); // fixme: this is not the widget's job //Ox.UI.$window.resize(that.size); // fixme: this is not the widget's job
@ -1297,6 +1289,21 @@ Ox.List = function(options, self) {
unloadPage(page + 1) unloadPage(page + 1)
} }
function updateItems() {
clear();
that.$content.empty();
self.$pages = [];
self.$pages[0] = Ox.Element()
.addClass('OxPage')
.css({
left: self.listMargin / 2 + 'px',
top: self.listMargin / 2 + 'px'
})
.appendTo(that.$content);
self.listLength = self.options.items.length;
loadItems();
}
function updatePages(pos, scroll) { function updatePages(pos, scroll) {
// only used if orientation is both // only used if orientation is both
clear(); clear();