GWT: ¿Cómo eliminar el elemento de su exterior?
Frecuentes
Visto 923 equipos
1
Tengo una Comercial widget as
<td class="GAS3MDBHJ">
<div class="GAS3MDBJJ">
<a class="gwt-Anchor" href="#export">Export</a>
</div>
</td>
I would like to remove this anchor element from it's root. How can I achieve it.
Si uso widget.getParentElement() , I need to write as ...
myanchor.getElement().getParentElement().getParentElement().removeFromParent();
Now it is in third level.If my widget is in level 7 or 8 or 9 , am I need to write getParentElement() repeatedly ? Has there anyway for fast code ?
I don't want to get it's parent element, I really want to get was outermost element.
1 Respuestas
2
Deberías simplemente llamar
anchor.removeFromParent();
It will remove the entire anchor element with all of its inner HTML. The result will be exactly the same if you call
anchor.getElement().removeFromParent();
because anchor.getElement() will give you the outer most element of this widget, just as you wanted.
If you start calling getParentElement(), you will remove more than your anchor widget.
contestado el 28 de mayo de 14 a las 15:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas gwt gwt2 or haz tu propia pregunta.
I want to remove my widget from
td
etiqueta. - CataclysmThe outermost parent would return <html> right? So what exactly do you wanna achieve? Removing the anchor as well as all its ancestors excluding the <td> element? - z00bs
Where is the issue in simply calling
anchor.removeFromParent();
? It works perfectly. - Braj@z00bs yes! you are right. I thought stupid thing. As you said "the outermost parent was <html>". - Cataclysm