Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: emberjs/ember.js
...
head fork: emberjs/ember.js
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
View
14 packages/ember-routing/lib/router.js
@@ -92,12 +92,24 @@ Ember.Router = Ember.StateManager.extend(
var targetState = this.findStateByPath(currentState, targetStateName);
Ember.assert("Your target state name " + targetStateName + " for event " + eventName + " did not resolve to a state", !!targetState);
- var hash = targetState.serialize(this, context);
+
+ var hash = this.serializeRecursively(targetState, context);
return this.urlFor(targetStateName, hash);
},
/** @private */
+ serializeRecursively: function(state, hash) {
+ hash = state.serialize(this, hash);
+ var parentState = state.get("parentState");
+ if (parentState && parentState instanceof Ember.Route) {
+ return this.serializeRecursively(parentState, hash);
+ } else {
+ return hash;
+ }
+ },
+
+ /** @private */
init: function() {
this._super();
View
38 packages/ember-routing/tests/router_test.js
@@ -148,6 +148,44 @@ test("router.urlForEvent works with changing context in the current state", func
});
+test("router.urlForEvent works for nested routes with a context", function() {
+ var router = Ember.Router.create({
+ location: location,
+ namespace: namespace,
+ root: Ember.Route.create({
+ index: Ember.Route.create({
+ route: '/',
+
+ showDashboardActivity: function(router) {
+ router.transitionTo('dashboard.activity');
+ },
+
+ eventTransitions: {
+ showDashboardActivity: 'dashboard.activity'
+ }
+ }),
+
+ dashboard: Ember.Route.create({
+ route: '/dashboard/:component_id',
+
+ activity: Ember.Route.create({
+ route: '/activity'
+ })
+ })
+ })
+ });
+
+ Ember.run(function() {
+ router.route('/');
+ });
+
+ equal(router.getPath('currentState.path'), "root.index", "precond - the router is in root.index");
+
+ var url = router.urlForEvent('showDashboardActivity', { id: 1 });
+ equal(url, "#!#/dashboard/1/activity");
+});
+
+
test("router.urlForEvent works with Ember.State.transitionTo", function() {
var router = Ember.Router.create({
location: location,

No commit comments for this range

Something went wrong with that request. Please try again.