Clear HTML div?

330 views
Skip to first unread message

Dennis Madsen

unread,
Dec 13, 2009, 5:09:15 PM12/13/09
to Google Web Toolkit
I've this HTML code:

<div id="entries">
<div class="loading">Loading guestbook entries..</div>
</div>

When calling a "RootPanel.get("entries").clear();" I expected that all
childs inside this div will be removed. But it doesn't. How can I
really clear the div?

Jan Ehrhardt

unread,
Dec 14, 2009, 9:08:43 AM12/14/09
to google-we...@googlegroups.com
RootPanel's clear method only removes GWT widgets. I would recommend to prevent the mixing of HTML in your host page and GWT widgets. Use a label widget instead.
If this isn't an option, you can do:

Element element = RootPanel.get("entries").getElement();
DOM.removeChild(element, 0);

This will manipulate the DOM directly and thus it's not recommended.

Regards
Jan Ehrhardt


--

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



Joe

unread,
Dec 14, 2009, 9:20:59 AM12/14/09
to Google Web Toolkit
Well Dennis,

First, I need to know the following tag <div id="entries"> is the main
tag in your Hosted HTML file??? if so, you should be able to remove
everything inside it with the RootPanel.get().clear() method.
However, if the tag <div id="entries"> was generated by the GWT
compiler from a FlowPanel, or FocusPanel or any other panel, than you
should call the panel.removeChild() method, which Im sure you're aware
of that already :)

If none of the above is your case, then please be more clear about it
and if possibly, you could post your Java code here.

Regards,
Joe
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>
> > .

Ashar Lohmar

unread,
Dec 15, 2009, 7:52:04 AM12/15/09
to Google Web Toolkit
you could try something like this

RootPanel.get("entries").setInnerHTML("");

the clear() method doesn't work as you expected because it comes from
HasWidgets and it removes only the Widgets that where added to the
panel with add()

if setInnerHTML(""); doesn't work as you wanted it, you could try to
make "loading" invisible
RootPanel.get("entries").getElement.getStyle().setProperty
("display","none");

Hope it helps
Good Luck
Reply all
Reply to author
Forward
0 new messages