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) {
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.ListItem({
construct: self.options.construct
@ -492,7 +492,9 @@ Ox.List = function(options, self) {
function emptyFirstPage() {
if (self.$pages[0]) {
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') {
that.$content.css({height: getListSize() + 'px'});
}
@ -851,7 +853,7 @@ Ox.List = function(options, self) {
sort: self.options.sort
}, function(result) {
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) {
var pos = offset + i;
self.$items[pos] = Ox.ListItem({
@ -1159,6 +1161,7 @@ Ox.List = function(options, self) {
}
function selectAsYouType(data) {
self.options.items({
keys: [self.options.unique],
query: {
@ -1372,7 +1375,7 @@ Ox.List = function(options, self) {
clear();
that.$content.empty();
self.$pages = [];
self.$pages[0] = $('<div>')
self.$pages[0] = Ox.Element()
.addClass('OxPage')
.css({
left: self.listMargin / 2 + 'px',