Make model hook (and everything else) fire when navigating from glob route to glob route


#1

For various reasons we need to define some routes in a very flexible way, like this:

Router.map(function() {
  // ... other routes
  this.route('page', { path: '/pages/*wildcard' });
});

The problem is if we’re on /pages/some-page/string and try to transitionTo('page', {wildcard: 'some/other/page-string'}), nothing is rendered. It’s literally a blank page. Putting a debugger in the page router model hook indicates that none of the routing machinery fires. The URL updates but nothing on the page. I’ve read that the model hook always fires when navigating to a route with a dynamic segment (which makes good sense, obviously you’ll need to fetch a new model!) but the same should be true for wildcard/glob routes. It seems that they were built with the assumption they would only be used for 404 pages…?

We tried to dynamically define all the weird page routes however that (1) is not really supported by Ember and (2) if you hack around it, it causes other problems (eg, you can’t pass a routerName to this.route so then you have to dynamically define the routes and register them with the app and it’s quite a pain).

Can anyone help?


Dynamically add routes at runtime?