Permalink
Browse files

Respect implicit index in Router#transitionTo

  • Loading branch information...
tomhuda
tomhuda committed Jan 12, 2013
1 parent 6a165ad commit 2426cb93ef9844d96219f399577e32fd7b667597
Showing with 13 additions and 3 deletions.
  1. +12 −2 packages/ember-routing/lib/system/router.js
  2. +1 −1 packages/ember/tests/routing/basic_test.js
@@ -62,8 +62,18 @@ Ember.Router = Ember.Object.extend({
this.notifyPropertyChange('url');
},
- transitionTo: function() {
- this.router.transitionTo.apply(this.router, arguments);
+ transitionTo: function(passedName) {
+ var args = [].slice.call(arguments), name;
+
+ if (!this.router.hasRoute(passedName)) {
+ name = args[0] = passedName + '.index';
+ } else {
+ name = passedName;
+ }
+
+ Ember.assert("The route " + passedName + " was not found", this.router.hasRoute(name));
+
+ this.router.transitionTo.apply(this.router, args);
this.notifyPropertyChange('url');
},
@@ -932,7 +932,7 @@ test("Parent route context change", function() {
App.PostsRoute = Ember.Route.extend({
events: {
showPost: function(context) {
- this.transitionTo('post.index', context);
+ this.transitionTo('post', context);
}
}
});

0 comments on commit 2426cb9

Please sign in to comment.