{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/10535","labels_url":"https://api.github.com/repos/emberjs/ember.js/issues/10535/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/ember.js/issues/10535/comments","events_url":"https://api.github.com/repos/emberjs/ember.js/issues/10535/events","html_url":"https://github.com/emberjs/ember.js/issues/10535","id":58941734,"number":10535,"title":"Initializer giving invalid router on container lookup","user":{"login":"zyllorion","id":10155785,"avatar_url":"https://avatars.githubusercontent.com/u/10155785?v=3","gravatar_id":"","url":"https://api.github.com/users/zyllorion","html_url":"https://github.com/zyllorion","followers_url":"https://api.github.com/users/zyllorion/followers","following_url":"https://api.github.com/users/zyllorion/following{/other_user}","gists_url":"https://api.github.com/users/zyllorion/gists{/gist_id}","starred_url":"https://api.github.com/users/zyllorion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zyllorion/subscriptions","organizations_url":"https://api.github.com/users/zyllorion/orgs","repos_url":"https://api.github.com/users/zyllorion/repos","events_url":"https://api.github.com/users/zyllorion/events{/privacy}","received_events_url":"https://api.github.com/users/zyllorion/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-25T17:47:05Z","updated_at":"2015-02-26T13:55:38Z","closed_at":"2015-02-26T13:43:10Z","body":"Hi,\r\n\r\nI have a problem trying to create an initialiser that allows me to control Embers router from outside of Ember#canary/cli in POJS.\r\n\r\nThis problem seems to occur mainly on deployed versions (using ember-cli `ember b`), and mainly seems to work on local `ember s` and through the same `ember b` when served through a local Apache.\r\n\r\nMy initializer is roughly the following:\r\n```\r\nexport function initialize(container, application) {\r\n    var router = container.lookup('router:main’);\r\n\t// above is incorrect – eager lookup\r\n    var transitionTo = function() {\r\n        var router = this.lookup('router:main’);\r\n\t//above is also incorrect – looked up way after initialization\r\n        Ember.run.schedule('afterRender', function() {\r\n            var router = this.lookup('router:main’);\r\n\t//guess what, this is also incorrect.\r\n            .... router.transitionTo.apply(router, tempargs);\r\n        }.bind(this));\r\n        window._amdBridge.show();\r\n    };\r\n    window._amdBridge.transitionTo = transitionTo.bind(container);\r\n```\r\nThe problem is that it gives a router with only the location property, whereas the same source run locally with `ember s` or through a local apache it's a fully populated router instance with router and targetState properties.  It does not seem to be consistent in either platform, and I have tried other ways (including much simpler than above), all with unreliable results.  I suspect there may be some kind of event that runs after the failing instance that initializes the router properly, maybe like https://github.com/emberjs/ember.js/blob/v1.10.0/packages/ember-application/lib/system/application.js#L343\r\n\r\nI’m looking for a solution, not the bug, as this is blocking release.\r\n\r\n1) is there a way to set the initializer to load last\r\n2) is there a way to access the container or router instances completely outside of Ember.\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/comments/76181301","html_url":"https://github.com/emberjs/ember.js/issues/10535#issuecomment-76181301","issue_url":"https://api.github.com/repos/emberjs/ember.js/issues/10535","id":76181301,"user":{"login":"OrKoN","id":399150,"avatar_url":"https://avatars.githubusercontent.com/u/399150?v=3","gravatar_id":"","url":"https://api.github.com/users/OrKoN","html_url":"https://github.com/OrKoN","followers_url":"https://api.github.com/users/OrKoN/followers","following_url":"https://api.github.com/users/OrKoN/following{/other_user}","gists_url":"https://api.github.com/users/OrKoN/gists{/gist_id}","starred_url":"https://api.github.com/users/OrKoN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrKoN/subscriptions","organizations_url":"https://api.github.com/users/OrKoN/orgs","repos_url":"https://api.github.com/users/OrKoN/repos","events_url":"https://api.github.com/users/OrKoN/events{/privacy}","received_events_url":"https://api.github.com/users/OrKoN/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T13:55:38Z","updated_at":"2015-02-26T13:55:38Z","body":"@zyllorion But do you make a lookup right before the transition? I've created a jsbin that is similar to how it works in my app http://emberjs.jsbin.com/lazizaxahu/4/edit?html,css,js,console,output"}}