How to disable anchor

I need to disable anchor. If I write myAnchor.setEnable(false) I can click and get result.

Hello,

The <a> tag doesn’t have a disabled attribute. To “disable” a link, you can remove its href attribute, or add a click handler that returns false.

In addition to this, you can hide the anchor with anchor.setVisible(false);

How remove attribute anchor? If I set myAnchore.setHref(“”) I get current page.html.

anchor.removeHref(); seems to do the trick

How?
17437002.jpg

You might need to update to Vaadin 12.0.2 (or flow 12.2) for that convenience method. For older versions, anchor.getElement().removeAttribute("href") does the same thing.

Thank you :slight_smile:

Now in 14.0.0.rc7 it has enable method but it doesn’t work.

It’s the same setEnabled() method as before, right? It’s still a bit misleading, but the previous comments in this this thread should still apply.

Olli Tietäväinen:
It’s the same setEnabled() method as before, right? It’s still a bit misleading, but the previous comments in this this thread should still apply.

Yes, sorry, just still doesn’t work with setEnabled but with removeHref()