tryRoutingTo

fun tryRoutingTo(pathQueryAndFragment: String, updateHistoryMode: UpdateHistoryMode = UpdateHistoryMode.PUSH, openLinkStrategy: OpenLinkStrategy = OpenLinkStrategy.IN_PLACE): Boolean(source)

Attempt to navigate internally within this site, or return false if that's not possible (i.e. because the path is external).

By internally, I mean this method expects a route path only -- no https:// origin in other words. "/", "/about", "/help/contact", and "user/123" are valid examples.

You will generally call this method like so:

onClick { evt ->
if (ctx.router.tryRoutingTo(...)) {
evt.preventDefault()
}

That way, either the router handles the navigation or the browser does.

Note that this method will automatically prepend this site's BasePath if it is configured and if pathQueryAndFragment is absolute.

See also: navigateTo, which, if called, handles the external navigation for you.

Parameters

pathQueryAndFragment

The path to a page, including (optional) search params and hash, e.g. "/example/path?arg=1234#fragment". See also the standards documentation.

updateHistoryMode

How this new path should affect the history. See UpdateHistoryMode docs for more details. Note that this value will be ignored if pathQueryAndFragment refers to an external link.