Skip to content

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

@herrherrmann

Description

@herrherrmann

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions