Ember.Router and redirectsTo gotcha
http://stackoverflow.com/questions/10823053/ember-router-not-updating-url-in-chrome-and-safari
by pearkes
HTML
<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
<script src="http://dl.dropbox.com/u/78715770/ember.js"></script>
JavaScript
App = Em.Application.create({
ready: function() {
// After 3 seconds transition to the 'tasks.show' state
Ember.run.later(function() {
App.get('stateManager').transitionTo('show');
}, 3000);
}
});
App.IndexView = Em.View.extend({
template: Em.Handlebars.compile(
'hello world from index'
)
});
App.ShowView = Em.View.extend({
template: Em.Handlebars.compile(
'hello world from show'
)
});
App.Router = Ember.Router.extend({
location: 'hash',
enableLogging: true,
root: Ember.State.extend({
index: Ember.State.extend({
route: '/',
redirectsTo: 'tasks'
}),
tasks: Ember.State.extend({
route: '/tasks',
index: Ember.ViewState.extend({
route: '/',
view: App.IndexView
}),
show: Ember.ViewState.extend({
route: '/show',
view: App.ShowView
})
})
})
});
App.initialize();