scphantm
scphantm

Reputation: 4543

GWT anchor to kick off new css class

Im building a nav menu and am struggling with something really simple here. In my UI binder i have this

<header class="{res.css.mainHeader}">
    <a href="#{res.css.mainNav}" class="{res.css.openMenu}">
        open
    </a>
    <a href="#" class="{res.css.closeMenu}">
        close
    </a>

    <h1>new header</h1>
    </header>

So when I write and test this in html, it works fine. you click on the word open, and everything animates, shows all the cool stuff, the world is a happy place. But i can't figure out how to translate this into GWT.

When I run the above code, I get this error

[WARN] [itrgwtprototype] - Escaping unsafe runtime String expression used for URI with UriUtils.fromString(). Use SafeUri instead: <a class='{res.css.openMenu}' href='#{res.css.mainNav}'> (:20)

But I have a sneaking suspicion that GWT has a better way to do it than SafeUri. How do i make this work? The CSS stuff is correct, but the anchor click is whats messed up.

thanks.

Upvotes: 0

Views: 154

Answers (1)

Fedy2
Fedy2

Reputation: 3207

You are setting the anchor href property with a css value (href="#{res.css.mainNav}").

If you want to translate it entirely in GWT you should listen to ClickEvent on you open menu and then do something like open a panel or something else. In order to do so you can replace the anchor with a Label (or InlineLabel) and listen on click events on it.

Upvotes: 1

Related Questions