improve removal of elements
This commit is contained in:
parent
7848277593
commit
7761b9dea4
3 changed files with 32 additions and 8 deletions
|
@ -321,8 +321,12 @@ Ox.Element = function(options, self) {
|
|||
};
|
||||
|
||||
that.empty = function() {
|
||||
that.$element.children('.OxElement').each(function() {
|
||||
Ox.UI.elements[$(this).data('oxid')].removeElement();
|
||||
that.$element.find('.OxElement').each(function() {
|
||||
var oxid = $(this).data('oxid'),
|
||||
element = Ox.UI.elements[oxid];
|
||||
//!element && Ox.print('NO ELEMENT FOR', oxid, this.className)
|
||||
//element && Ox.print('OK', oxid, this.className)
|
||||
element && element.removeElement(false);
|
||||
});
|
||||
that.$element.empty();
|
||||
return that;
|
||||
|
@ -378,14 +382,33 @@ Ox.Element = function(options, self) {
|
|||
removeElement <function> Removes an element object and its event handler
|
||||
() -> <obj> This element
|
||||
@*/
|
||||
that.remove = that.removeElement = function() {
|
||||
that.$element.children('.OxElement').each(function() {
|
||||
Ox.UI.elements[$(this).data('oxid')].removeElement();
|
||||
that.remove = that.removeElement = function(remove) {
|
||||
//remove !== false && (len = Ox.len(Ox.UI.elements));
|
||||
///*
|
||||
remove !== false && that.$element.find('.OxElement').each(function() {
|
||||
var oxid = $(this).data('oxid'),
|
||||
element = Ox.UI.elements[oxid];
|
||||
//!element && Ox.print('NO ELEMENT FOR', oxid, this.className)
|
||||
//element && Ox.print('OK', oxid, this.className)
|
||||
element && element.removeElement(false);
|
||||
});
|
||||
//*/
|
||||
Ox.Focus.remove(that.id);
|
||||
delete self.$eventHandler;
|
||||
delete Ox.UI.elements[that.id];
|
||||
that.$element.remove();
|
||||
that.$tooltip && that.$tooltip.remove();
|
||||
remove !== false && that.$element.remove();
|
||||
/*
|
||||
if (remove !== false) {
|
||||
var orphaned = 0;
|
||||
Ox.forEach(Ox.UI.elements, function(element) {
|
||||
if (!element.parent().length) {
|
||||
orphaned++;
|
||||
}
|
||||
});
|
||||
Ox.print('LEN', len, '-->', Ox.len(Ox.UI.elements), 'orphaned:', orphaned);
|
||||
}
|
||||
*/
|
||||
return that;
|
||||
};
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ Ox.forEach($('<div>'), function(val, key) {
|
|||
// if the $element of an ox object was returned
|
||||
// then return the ox object instead
|
||||
// so that we can do oxObj.jqFn().oxFn()
|
||||
return ret && ret.jquery && Ox.UI.elements[id = ret.data('oxid')] ?
|
||||
Ox.UI.elements[id] : ret;
|
||||
return ret && ret.jquery && Ox.UI.elements[id = ret.data('oxid')]
|
||||
? Ox.UI.elements[id] : ret;
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
|
|
|
@ -201,6 +201,7 @@ Ox.SplitPanel = function(options, self) {
|
|||
//self.options.elements[pos].element.replaceWith(element.$element.$element || element.$element)
|
||||
//self.options.elements[pos].element = element;
|
||||
///*
|
||||
Ox.print('REPLACE ELEMENT')
|
||||
self.options.elements[pos].element.replaceWith(
|
||||
self.options.elements[pos].element = element
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue