I have an Ember app that has a plugin architecture. These plugins will be able to add routes and resources to the Router.map. I load in the js files that add to the routes with AJAX calls.
The problem is that going immediately to #/some-plugin-route gives me a 404 as the app hasn't yet loaded in the route. However, going to / then #/some-plugin-route resolves just fine as the routes have been loaded.
I tried putting the AJAX calls into my Router.map call in the main app, but then it AJAXed in everything on every transition. How do I make the application load the plugins before deciding a route should redirect to the 404 page?
404 Controller code:
window.App.notFoundController = Ember.Controller.extend({
redirect: function () {
var url = this.router.location.formatURL("/not-found");
if (window.location.pathname !== url) {
this.transitionTo("/not-found");
}
}
});
Aucun commentaire:
Enregistrer un commentaire