How to set attribs in GWT?
- by Jonas Byström
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!