views:

46

answers:

0

I've got a gwt application and I want to scroll to the top of a page using this method:

public static native void scrollTop() /*-{
  $wnd.scroll(0, 0);
}-*/;

The method is called in the onClick-method of a TreeNodeListenerAdapter:

new TreeNodeListenerAdapter() {
  @Override
  public void onClick(Node node, EventObject e) {
    scrollTop();
  }
}

This does not work and I don't know why. When I put an alert inside my method:

$wnd.alert("Treenode clicked");

I get to see the alert but the page is not scrolled. What am I missing here?