-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trying to get location during route's hook gives you the previous location #10906
Comments
a HUGE +1 This jsBin helps to show the issue: http://jsbin.com/hizacuyobi#/posts I think the following hooks / events should have access to the new url.
Needing to call In my own app, I did this to get around the issue
I completely understand that until If the intent is to delay updating the url until the onscreen content has/is rendering, I would suggest providing an explicit and documented means of accessing the new url from within hooks and the didTransition event. |
@runspired Thanks for your workaround. I used the Route = Ember.Route.extend
actions:
didTransition: ->
Ember.run.schedule 'afterRender', @, ->
@formatTitle()
formatTitle: ->
urlSplit = window.location.href.split("/")
... |
Tagging this as something to be re-checked against the latest canary |
per @runspired suggestion:
I think this is a documentation issue to surface when the transition has made it to a new URL. cc/ @locks @acorncom |
This issue came up during my implementation of the router service RFC. I identified the issue (it was in |
This issue can be closed. |
When I try to get my url with
window.location
object in an Ember route's hook, I actually get the previous location. I dug around and this worksbut only sometimes so it may be a race condition, in which case it sometimes updates on time and sometimes it doesn't. Only when I schedule it from the afterModel hook, it works consistently so far.
The didTransition event in particular should have the accurate full url at least.
Either way it's a problem that it is not at all obvious from documentation or anywhere that this is doable. So over 1 hour down the drain to get the url - something which the browser gives you readily and every developer knows how to do in 1 second... unless your framework obscures it and its route hooks are out of sync with the browser...
The text was updated successfully, but these errors were encountered: