3

Can I use Iron-Router in Meteor to push a new state onto the browser's history, without going to a new URL?

I would like to show a modal but enable to user to hide it again using the back button.

dalgard
  • 3,446
  • 2
  • 19
  • 28

2 Answers2

1

Haven't tried this, but I think something based on

Router.go(Router.current().request.url + '/modal')`

might work. You define your route with an optional parameter, and if it's 'modal' then display the modal. That may lead to problems if you have URL parameters, in which case you'd have to get more clever with the URL.

Soren
  • 13,623
  • 4
  • 34
  • 66
Dan Dascalescu
  • 110,650
  • 40
  • 276
  • 363
  • Thanks, but the premise is to not change the URL. Pushing state to history without reflecting it in the address bar is a valid and useful UX pattern. – dalgard Feb 27 '14 at 08:44
1

AFAIK you can't push browser state "silently" with the Iron Router package. However you can use one of these methods or the HTML 5 History API package that wraps this package - https://github.com/devote/HTML5-History-API

Community
  • 1
  • 1
hharnisc
  • 907
  • 7
  • 11