I am trying to detect when a route transition occurs. I\'ve located this code snippet inside the latest version of Ember (v1.0.0-pre.4
) that handles the transitions
UPDATED ANSWER
You can now simply bind an observer on the router's didTransition
event:
App.Router.reopen({
doSomethingOnUrlChange: function() {
console.log(this.get('url'));
}.on('didTransition')
});
see working example: http://jsfiddle.net/Sly7/3THD7/
DEPRECATED ANSWER BELOW
In the snippet here, there is set(appController, 'currentPath', path);
I think you can put an observer on this property.
I don't know exactly where you want to be notified, but it's possible to do it in the ApplicationController itself.
App.ApplicationController = Ember.Controller.extend({
currentPathDidChange: function(){
// the currentPath has changed;
}.observes('currentPath');
});
See this working fiddle for example: http://jsfiddle.net/qKrwU/