ryanto / ember-flash-message

Flash message for Ember.JS templates.
49 stars 23 forks source link

Make flash messages work for route resources #3

Closed wnm closed 10 years ago

wnm commented 10 years ago

Hi there, I realised that when setting a flash message and then transitioning into a route defined as resource, the flash message is lost.

App.Router.map(function() {
  this.resource('posts', { path: '/posts' }, function() {
    this.route('new');
  });
});
this.flashMessage("Create a new post");
this.transitionTo('posts.new');

For whatever reason the "activate" hook is called twice.(Probably once for PostsRoute, and once for PostNewRoute in the example above).

The first time it is called with routeName "post", second time with "post.new".

The problem is, that the first time the hook is called the message gets set, so on the second time it is lost. I fixed it by comparing the routeName to the transition's targetName.

ryanto commented 10 years ago

:star: