From fe8c97db242165fdeb4deea57a0c3c164ac3d4de Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 17 Jun 2012 19:13:18 +0200 Subject: [PATCH] in Ox.List, handle Ox.TreeList items update --- source/Ox.UI/js/List/List.js | 61 ++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/source/Ox.UI/js/List/List.js b/source/Ox.UI/js/List/List.js index 4c2a8bd8..56c96149 100644 --- a/source/Ox.UI/js/List/List.js +++ b/source/Ox.UI/js/List/List.js @@ -70,20 +70,24 @@ Ox.List = function(options, self) { .options(options || {}) .update({ items: function() { - if (Ox.isArray(self.options.items)) { - self.options.items = Ox.api(self.options.items, { - cache: true, - sort: self.options.sort, - sums: self.options.sums, - unique: self.options.unique - }); - /* - self.listLength = self.options.items.length; - updateSelected(); - updateSort(); - */ + if (!self.isAsync) { + updateItems(); + } else { + if (Ox.isArray(self.options.items)) { + self.options.items = Ox.api(self.options.items, { + cache: true, + sort: self.options.sort, + sums: self.options.sums, + unique: self.options.unique + }); + /* + self.listLength = self.options.items.length; + updateSelected(); + updateSort(); + */ + } + updateQuery(); } - updateQuery(); }, selected: function() { var previousSelected = self.selected; @@ -239,20 +243,8 @@ Ox.List = function(options, self) { ]; } - if (!self.isAsync) { - 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(); - } + !self.isAsync ? updateItems() : updateQuery(); + that.bindEvent(self.keyboardEvents); //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) } + 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) { // only used if orientation is both clear();