Ember: Bubble action from component to application controller

Marco Prins

I have a component in ember, which needs to send an action (with one parameter) to the application controller. No matter where this component is rendered, it needs to call the exact same action, on application controller.

application-controller

export default Ember.Controller.extend({
  actions: {
    addAlert: function(message) {
      this.set('message', message);
    },
    removeAlert: function(message) {
      this.set('message', message);
    }
  }
});

How do I handle this? From start, to end.

Patsy Issa

Actions don't bubble up through controllers, when an action is triggered it will go through the current route's controller, if nothing handles it there it bubbles up to the current route all the way up to the top level route (application).

If that action has to set a property on the controller you can set it directly from the application route (although it is not recommended).

// routes/application.js
actions {
  addAlert(message) {
      this.controller.set('message', message);
    },
    removeAlert(message) {
      this.controller.set('message', message);
    }
}

For more information read up on action bubbling.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling controller action from Ember 2.0 component

From Dev

Bubble up events from ember component

From Dev

Return a promise from a controller action in Ember?

From Dev

Ember: send action from one component to another

From Dev

Access jquery event from ember component action

From Dev

Ember: send action from one component to another

From Dev

Access jquery event from ember component action

From Dev

Cannot get Ember action to bubble

From Dev

Sending an action from a sub component to parent component in Ember 2.2

From Dev

Ember Component Action Not Bubbling

From Dev

How to bubble events from inner components to application controller in Emberjs?

From Dev

Trigger action on controller from route after model has resolved in Ember

From Dev

Call a action method from a controller method in Ember.JS

From Dev

How to send an action from a Ember component to a View that wraps it?

From Dev

Sending action from component to route in ember.js

From Dev

How to send an action from a Ember component to a View that wraps it?

From Dev

Call action from parent component in Ember 2.x

From Dev

How to get the outer parent controller from inside an ember component?

From Dev

Ember controller: nothing handled the action

From Dev

Ember nested component action not bubbling

From Dev

How to programatically add component via controller action in ember 2.x

From Dev

How to handle action "sent" by Ember component in wrapping view or view's controller?

From Dev

binding controller object to a component in ember

From Dev

include bower component in Ember Controller

From Dev

binding controller object to a component in ember

From Dev

In Ember, how can I handle an action sent from a controller in another controller

From Dev

Global controller for application in Ember Js

From Dev

How can I bubble up an Ember action inside a callback function?

From Dev

How to run action in Ember Controller afterRender

Related Related

  1. 1

    Calling controller action from Ember 2.0 component

  2. 2

    Bubble up events from ember component

  3. 3

    Return a promise from a controller action in Ember?

  4. 4

    Ember: send action from one component to another

  5. 5

    Access jquery event from ember component action

  6. 6

    Ember: send action from one component to another

  7. 7

    Access jquery event from ember component action

  8. 8

    Cannot get Ember action to bubble

  9. 9

    Sending an action from a sub component to parent component in Ember 2.2

  10. 10

    Ember Component Action Not Bubbling

  11. 11

    How to bubble events from inner components to application controller in Emberjs?

  12. 12

    Trigger action on controller from route after model has resolved in Ember

  13. 13

    Call a action method from a controller method in Ember.JS

  14. 14

    How to send an action from a Ember component to a View that wraps it?

  15. 15

    Sending action from component to route in ember.js

  16. 16

    How to send an action from a Ember component to a View that wraps it?

  17. 17

    Call action from parent component in Ember 2.x

  18. 18

    How to get the outer parent controller from inside an ember component?

  19. 19

    Ember controller: nothing handled the action

  20. 20

    Ember nested component action not bubbling

  21. 21

    How to programatically add component via controller action in ember 2.x

  22. 22

    How to handle action "sent" by Ember component in wrapping view or view's controller?

  23. 23

    binding controller object to a component in ember

  24. 24

    include bower component in Ember Controller

  25. 25

    binding controller object to a component in ember

  26. 26

    In Ember, how can I handle an action sent from a controller in another controller

  27. 27

    Global controller for application in Ember Js

  28. 28

    How can I bubble up an Ember action inside a callback function?

  29. 29

    How to run action in Ember Controller afterRender

HotTag

Archive