gwtmvp4g

How do I disable/enable anchor in GWT?


Possible Duplicate:
How to enable or disable an anchor using jQuery?

I'm having a hard time disabling the anchor. I've read that there's an existing bug with Anchor.SetEnabled.

anchor().setEnabled(false) does not work due to browser constraints. However, is there another way to disable/enable the link?


Solution

  • // to disable the anchor
    disabled = anchor.addClickHandler(new ClickHandler() {
       @Override
       public void onClick(ClickEvent event) {
          event.preventDefault();
       }
    });
    
    // to re-enable it.
    disabled.removeHandler();