V7 Navigator Back

Is there a programatic way to navigate back to the previous view with the Navigator class?

The closest thing I have found:

getMainWindow().executeJavaScript("history.back()");

But this is tacky. Is there a better way?

There’s currently no builtin support for navigation history, although
an enhancement ticket
exists. If your “back” should mean “go back in the browser”, then
history.back()
is pretty much the way to do it. On the other hand, if you want “back” to mean “push a new view to the browser history stack that happens to be the same as the previous view”, you can quite easily maintain a server-side stack of view names and simply use
navigator.navigateTo(historyStack.pop())
.

Incidentally, I wrote a browser history extension a couple of weeks back that exposes a server-side API to the
window.history
object, also supporting HTML5 pushState and enabling the Navigator to use pushState. Should probably publish it at some point…

Nice, sounds good.

I have encapsulated the javascript call and will have a look at doing something a bit cleaner later on.

Thanks for the response.