diff --git a/source/Ox.UI/js/Core/Ox.Element.js b/source/Ox.UI/js/Core/Ox.Element.js index caa09be0..889b1dad 100644 --- a/source/Ox.UI/js/Core/Ox.Element.js +++ b/source/Ox.UI/js/Core/Ox.Element.js @@ -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 Removes an element object and its event handler () -> 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; }; diff --git a/source/Ox.UI/js/Core/Ox.JQueryElement.js b/source/Ox.UI/js/Core/Ox.JQueryElement.js index 93719106..f164c983 100644 --- a/source/Ox.UI/js/Core/Ox.JQueryElement.js +++ b/source/Ox.UI/js/Core/Ox.JQueryElement.js @@ -49,8 +49,8 @@ Ox.forEach($('
'), 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); diff --git a/source/Ox.UI/js/Panel/Ox.SplitPanel.js b/source/Ox.UI/js/Panel/Ox.SplitPanel.js index 714f18c6..db353b6a 100644 --- a/source/Ox.UI/js/Panel/Ox.SplitPanel.js +++ b/source/Ox.UI/js/Panel/Ox.SplitPanel.js @@ -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 );