Anchor.wrap with GQuery

8 views
Skip to first unread message

jd

unread,
Dec 9, 2009, 1:58:21 AM12/9/09
to Google Web Toolkit
Hi,

I am using GQuery to return elements that I want to attach
ClickHandlers to like this:


GQuery h2s = $("#header > h2 > a");
Anchor lowestPriceAnchor = Anchor.wrap(h2s.get(0));

But I am getting an exception:


java.lang.AssertionError: A widget that has an existing parent widget
may not be added to the detach list
at com.google.gwt.user.client.ui.RootPanel.detachOnWindowClose
(RootPanel.java:136)
at com.google.gwt.user.client.ui.Anchor.wrap(Anchor.java:59)

Does anyone know what I am going wrong here?

Cheers,

John

Thomas Broyer

unread,
Dec 9, 2009, 4:59:28 AM12/9/09
to Google Web Toolkit
The element you're trying to wrap is a child of an element that's the
"root" element of a widget. A widget is supposed to control its
subtree, so wrapping a widget's child element in another widget is
prohibited, as the "parent" widget would be aware of it.

John Patterson

unread,
Dec 9, 2009, 6:48:31 AM12/9/09
to google-we...@googlegroups.com

On 9 Dec 2009, at 16:59, Thomas Broyer wrote:

> The element you're trying to wrap is a child of an element that's the
> "root" element of a widget. A widget is supposed to control its
> subtree, so wrapping a widget's child element in another widget is
> prohibited, as the "parent" widget would be aware of it.

My question is _why_ is this element already owned and what can be
done about it.

Thomas Broyer

unread,
Dec 9, 2009, 10:13:48 AM12/9/09
to Google Web Toolkit
First find the offending element (either set a breakpoint in
RootPanel::isElementChildOfWidget in DevMode, or look for a parent
element with a __listener property using whichever tool your like in
"prod mode" –Firebug, Web inspector, Developer Tools, etc.–), then try
to understand why it could "be a widget" already; but without seeing
your code it's impossible to help you further more...
Reply all
Reply to author
Forward
0 new messages