Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set class/type when using in controller? #26

Open
herrherrmann opened this issue Feb 25, 2015 · 0 comments
Open

How to set class/type when using in controller? #26

herrherrmann opened this issue Feb 25, 2015 · 0 comments

Comments

@herrherrmann
Copy link

Hello there,

I want to trigger flash messages from within controllers because that's where my actions lie.
Is there a way to set the class/type of the flashmessage within a controller, too?

I already tried stuff like:

App.PostController = Ember.ObjectController.extend({
  needs: ['flashMessage'],
  actions: {
    // ...
    removePost: function () {
      var confirmed = confirm("Are you sure you want to remove the post \"" + this.get('title') + "\"?");
      if (confirmed) {
        var post = this.get('model');
        post.deleteRecord();
        post.save();
        var flashMessage = this.get('controllers.flashMessage');
        this.transitionTo('posts')
        .then(function() {
          flashMessage.set('message', 'Blog post removed!');
          flashMessage.set('message.type', 'alert alert-success');
        });
      }
    }
  }
});

... but my resulting flashmessage keeps having an empty class attribute.

P.S.: I'm using @treygriffith's version since I'm on ember 1.10.0.
P.P.S.: I just noticed that the message text isn't showing either! So both parameters are not being send to the output properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant