How do I disable/enable anchor in GWT?

3.7k Views Asked by At

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?

3

There are 3 best solutions below

2
On BEST ANSWER
// to disable the anchor
disabled = anchor.addClickHandler(new ClickHandler() {
   @Override
   public void onClick(ClickEvent event) {
      event.preventDefault();
   }
});

// to re-enable it.
disabled.removeHandler();
0
On

You can for example change href, or make onClick events no-ops.

0
On

I had a similar problem. the most suitable solution for me was to download the custom Anchor class given in the end of this issue and use it instead of the GWT Anchor. It work from the first try !