Changing url with replaceState loads the URL instead of faking it

I’m trying to change the URL in the address-bar using window.history.replaceState in order to keep track of the state in the URL by just faking its content, but iron-router is instead actually changing the route and not letting me just manage what the address bar looks like by my own.

Are there any hooks that iron-router is using that trigger when I call window.history.replaceState in a template event?

For your reference, what I’m trying to do is to change the URL when a modal is opened, and go back to the previous URL when the modal is closed. I don’t want to actually go to the url because the view of a modal is different than the actual detail view, pretty much how Instagram works on web when you open a picture vs. when you open a picture by entering its URL.

Here’s the relevant code:

'click .open-modal': function(e, t) {
    let modal = $('[data-remodal-id=modal-issue]').remodal();
    window.history.replaceState({}, null, '/url/for/modal')

when I click the button and the modal is opened, iron-router is trying to actually go to /url/for/modal instead of sitting back and let me fake the URLs by my own.

Any ideas on how to achieve this with Meteor + Iron Router?

1 Like