Hi BJ,
I am sorry for the misunderstanding. this all works fine. I am talking
about DOM eventlisteners
(https://developer.mozilla.org/en-US/docs/Web/API/EventListener) for events
like "resize" that I registered at the window object at creation time and I
do not have a chance to remove them. It's not about nodes and their
deletion - its about cleaning the environment up outside the widget.
Without a destructor I have to the following to get an event removed:
var resizeHandler = function() {
// remove the listener, if the object is not part of the dom anymore
// https://developer.mozilla.org/en-US/docs/Web/API/Node.contains
if(!document.body.contains(this.parentDomNode)) {
window.removeEventListener("resize", resizeHandler);
return;
}
this.repaint();
}.bind(this)
window.addEventListener("resize", resizeHandler, false);
Regards
Felix
On Saturday, November 1, 2014 10:09:27 PM UTC+1, BJ wrote:
>
>
> Hi Felix,
> how are you creating you entries in the dom? The render mechanism in the
> widget tree creates dom nodes, and when a widget refreshes itself these dom
> nodes are removed from the page, effectively deleting them and all there
> offspring nodes. (see removeChildDomNodes()) - so no destructor is
> necessary.
>
> On Saturday, November 1, 2014 4:40:59 PM UTC, Felix Küppers wrote:
>>
>> Hi,
>>
>> I have another question :)
>>
>> I need to register to window resize events to calculate the size of my
>> canvas as it's not possible with css without changing too much of TW.
>>
>> However, once my widget is destroyed, I cannot remove the eventlisteners
>> and next time the widget is created again, it creates another resize
>> listener.
>>
>> *Question:* So is there a destructor that is called on my widget
>> instance in which I can remove the listeners I originally created at
>> instantiation?
>>
>> Regards
>> Felix
>>
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.