Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember Route.transitionTo removed

Tags:

ember.js

I've just upgraded to the latest ember and the following code is breaking, I have a number of these actions defined on the router

App.Router = Em.Router.extend
  showUser: Ember.Route.transitionTo('root.users.user')

with the following error message

Uncaught TypeError: Object Ember.Route has no method 'transitionTo'

There is nothing in the changelog about this change but it has been removed from the Route class. It still exists on the instance.

How else can I define actions like these on the router which I can call from elsewhere?

like image 537
dagda1 Avatar asked Jan 05 '13 09:01

dagda1


2 Answers

Recently ember introduced a new router. Their guides got pretty mature, so please check these how to implement your routings.

In short:

App.Router.map(function(match) {
  match('/').to('index');
  match('/posts').to('posts');
});

App.IndexRoute = Ember.Route.extend({
  redirect: function() {
    this.transitionTo('posts');
  }
});
like image 107
bazzel Avatar answered Oct 05 '22 04:10

bazzel


If you're building from master you will find ember-old-router.js in the dist directory which will allow your code based on the "old" router to continue to run while you transition to the new way of doing things.

To get an idea of how things are now check out this gist or the official site's guide section.

like image 40
chrixian Avatar answered Oct 05 '22 04:10

chrixian