Search code examples
ember.jsember-router

initial route is not in history -- ember.js location: "history"


I'm using ember.js with location: "history". The first route of my site that is loaded (i.e. the one I type into the URL) renders fine. I can click a linkTo anchor to get to a second route, but when I click the back button to return to the first route (the initially loaded one), it is not routed.

Is there something I can do to push that initial route into the history? Should I need to do this?

My route mapping looks like this:

App.Router.reopen({
  location: "history"
});

App.Router.map(function() {
  this.resource("foods", function(){
    this.route("index", {path: "/"});
  });
  this.route("fourOhFour", { path: "*:"});
});

Note: it doesn't seem to matter whether I begin at http://mysite.example/ or http://mysite.example/foods. In either case, attempting to back onto the initially loaded route has no effect.

I believe that perhaps I should be pushing something into the history but don't know how to do it, nor why I should need to. "fourOhFour" is just my handler for undefined routes, BTW. I don't think it's related to this issue.

Any advice welcome.


Solution

  • Good catch on this one. I just ran into the same issue and started digging around into the Ember.HistoryLocation. I found this commit on github to a fork of ember.js that fixed the problem for me:

    https://github.com/teddyzeenny/ember.js/commit/c2c483dc592bb926c210e2c4c174dba7314d18dd

    ... I actually just merged the diff from this commit to my local copy of ember.js, and am now running history routing just fine for dev, which is good enough to keep me going until this will get wedged back into the main project.