use Ox.Element, not $, so that inner Ox.Elements get collected on remove; when emptying first page, collect Ox.Elements

This commit is contained in:
rlx 2014-09-23 21:06:27 +02:00
parent 2a6ea64eed
commit 8f5ff8c6ee

View file

@ -377,7 +377,7 @@ Ox.List = function(options, self) {
} }
function constructEmptyPage(page) { function constructEmptyPage(page) {
var i, $page = $('<div>').addClass('OxPage').css(getPageCSS(page)); var i, $page = Ox.Element().addClass('OxPage').css(getPageCSS(page));
Ox.loop(getPageLength(page), function() { Ox.loop(getPageLength(page), function() {
Ox.ListItem({ Ox.ListItem({
construct: self.options.construct construct: self.options.construct
@ -492,7 +492,9 @@ Ox.List = function(options, self) {
function emptyFirstPage() { function emptyFirstPage() {
if (self.$pages[0]) { if (self.$pages[0]) {
if (self.options.type == 'text') { if (self.options.type == 'text') {
self.$pages[0].find('.OxEmpty').remove(); self.$pages[0].find('.OxEmpty').each(function() {
Ox.getOxElement($(this)).remove();
});
} else if (self.options.orientation == 'both') { } else if (self.options.orientation == 'both') {
that.$content.css({height: getListSize() + 'px'}); that.$content.css({height: getListSize() + 'px'});
} }
@ -851,7 +853,7 @@ Ox.List = function(options, self) {
sort: self.options.sort sort: self.options.sort
}, function(result) { }, function(result) {
var $emptyPage = self.$pages[page]; var $emptyPage = self.$pages[page];
self.$pages[page] = $('<div>').addClass('OxPage').css(getPageCSS(page)); self.$pages[page] = Ox.Element().addClass('OxPage').css(getPageCSS(page));
result.data.items.forEach(function(v, i) { result.data.items.forEach(function(v, i) {
var pos = offset + i; var pos = offset + i;
self.$items[pos] = Ox.ListItem({ self.$items[pos] = Ox.ListItem({
@ -1159,6 +1161,7 @@ Ox.List = function(options, self) {
} }
function selectAsYouType(data) { function selectAsYouType(data) {
self.options.items({ self.options.items({
keys: [self.options.unique], keys: [self.options.unique],
query: { query: {
@ -1372,7 +1375,7 @@ Ox.List = function(options, self) {
clear(); clear();
that.$content.empty(); that.$content.empty();
self.$pages = []; self.$pages = [];
self.$pages[0] = $('<div>') self.$pages[0] = Ox.Element()
.addClass('OxPage') .addClass('OxPage')
.css({ .css({
left: self.listMargin / 2 + 'px', left: self.listMargin / 2 + 'px',