How to set attribs in GWT?
Posted
by Jonas Byström
on Stack Overflow
See other posts from Stack Overflow
or by Jonas Byström
Published on 2010-06-17T14:17:07Z
Indexed on
2010/06/17
14:33 UTC
Read the original article
Hit count: 235
I'm not getting any effect out of DOM.setElementAttribute
, am I doing something wrong?
class MyListBox extends com.google.gwt.user.client.ui.ListBox {
....
protected void setHoverAutoWidth() {
addDomHandler(new MouseOverHandler() {
public void onMouseOver(MouseOverEvent event) {
DOM.setElementAttribute(getElement(), "width", "auto");
}
}, MouseOverEvent.getType());
addDomHandler(new BlurHandler(){
public void onBlur(BlurEvent event) {
DOM.setElementAttribute(getElement(), "width", "100px");
}
}, BlurEvent.getType());
}
}
(I know there are less hacky ways to change the width than to set the style attribute directly, but I don't care about css right now.)
Edit: Oops, just realized that width does not change the style width, just adds a width attribute to the tag (which explains why nothing happens). Any suggestions on how to modify the style are still welcome!
© Stack Overflow or respective owner