[ 1 post ]

Alex Xiao

  • Username: alexx
  • Joined: Mon Jun 04, 2012 2:44 pm
  • Posts: 3
  • Offline
  • Profile

Accessing WidgetParent child DOM nodes in after removeChild

Post Posted: Mon Jun 25, 2012 5:04 pm
+0-
We have a JavaScript object that extends Widget and uses WidgetParent.

We attached an after removeChild event handler to an instance of that object that accessed the DOM nodes of the children.

We found that if we attached our event handler before we called render() on the Widget, then the child DOM node was still present.

We discovered that this is because the DOM node is not removed in the remove function, but in another after removeChild event handler that is added by the render function.

So, because we added ours before render was called, our handler got called first.

We have since changed this code to use the WidgetParent.each() function to access the children instead of directly accessing the DOM nodes, which I definitely agree is a much better approach.

However, I'm still wondering if the fact that the order you attach after removeChild event handlers and call render affects whether the DOM node will still be present or not is a bug, or should at least be documented, since this behaviour wasn't expected.

Can anybody provide any insight here? Should I just raise a bug, or is the whole idea of trying to access the DOM nodes implicitly wrong.
  [ 1 post ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum