1
0
Fork 0
forked from 0x2620/oxjs

avoid leaks by adding custom empty/remove/replaceWith functions to Ox.Element

This commit is contained in:
rlx 2011-11-01 19:56:11 +00:00
commit 7848277593
4 changed files with 41 additions and 14 deletions

View file

@ -100,6 +100,7 @@ Ox.Element = function(options, self) {
var that = new Ox.JQueryElement(
$(self.options.element || '<div>')
)
.addClass('OxElement')
.mousedown(mousedown);
if (self.options.tooltip) {
@ -319,6 +320,14 @@ Ox.Element = function(options, self) {
return that;
};
that.empty = function() {
that.$element.children('.OxElement').each(function() {
Ox.UI.elements[$(this).data('oxid')].removeElement();
});
that.$element.empty();
return that;
};
/*@
gainFocus <function> Makes an element object gain focus
() -> <obj> This element object
@ -369,12 +378,20 @@ Ox.Element = function(options, self) {
removeElement <function> Removes an element object and its event handler
() -> <obj> This element
@*/
that.removeElement = function() {
that.loseFocus();
that.remove = that.removeElement = function() {
that.$element.children('.OxElement').each(function() {
Ox.UI.elements[$(this).data('oxid')].removeElement();
});
Ox.Focus.remove(that.id);
delete self.$eventHandler;
that.remove();
// fixme: ok to comment out the following line?
delete Ox.UI.elements[that.id];
that.$element.remove();
return that;
};
that.replaceWith = function($element) {
$element.insertAfter(that);
that.remove();
return that;
};