Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qxWeb dispose (BZ#7674) #7710

Closed
qx-bug-importer opened this issue Aug 22, 2013 · 1 comment
Closed

qxWeb dispose (BZ#7674) #7710

qx-bug-importer opened this issue Aug 22, 2013 · 1 comment
Labels
enhancement New features, give me a PR!!!

Comments

@qx-bug-importer
Copy link

Joaquín Fernández (jf) wrote:

I have some qx classes using qxWeb elements but i would like to dispose them using a framework method.

For example, in constructor:

construct : function() {
.
.
.
this.__html = qxWeb.create('<span>')
.
.
.
this.__html.on ('click', ........)
.
.
.
}

I would like to do in destructor:

destruct : function() {
.
.
.
this._disposeObjects('__html')
.
.
.
}

But qxWeb don't have a dispose method.
I think qxWeb should have a method for disposing an instance removing html from DOM, listeners attached and everything related to element and childrens.

I am copying a simple dispose method used in my code but this functionality should be in qx core.

qxWeb.$attach({
dispose : function ()
{
this.removeAllListeners();
this.forEach(qx.dom.Element.remove);
},
removeAllListeners : function ()
{
for (var _index = 0, _length = this.length; _index < _length; ++_index) {
var _element = this[_index];
var _qxElement = qxWeb(_element);
for (var _i in _element) {
if (_element.hasOwnProperty(_i)) {
try {
if (_element[_i].classname == 'qx.event.Emitter') {
var _emitter = _element[_i];
var _listeners = _emitter.getListeners();
for (var _event in _listeners) {
if (_listeners.hasOwnProperty(_event)) {
var _eventListeners = _listeners[_event];
for (var _j = 0, _l = _eventListeners.length; _j < _l; ++_j) {
_qxElement.off(
_event,
_eventListeners[_j].listener,
_eventListeners[_j].ctx
);
}
}
}
}
} catch (e) {
}
}
}
}
}
});

Remarks:

  • If qx.module.Event has a getEmitter method, the first for loop should be unnecesary.
  • If qx.event.Emitter had a dispose method, the second loop should be unnecesary.
  • I think a method for removing all listeners in elements should be in qxWeb core.
@qx-bug-importer
Copy link
Author

Martin Wittemann (@wittemann) wrote:

Move open issues to RESOLVED – LATER, whose last comment is older than a year.

@qx-bug-importer qx-bug-importer added enhancement New features, give me a PR!!! C:website labels May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, give me a PR!!!
Projects
None yet
Development

No branches or pull requests

1 participant