vendredi 24 avril 2015

Ember component flexible ancestor communication

I'm coming from the angularjs world and am having trouble writing a component that can communicate upwards amongst other ancestor components. Here is an example:

{{#menus}}
  {{#menus-content}}
    {{close-menu}} Button to close menu
  {{/menus-content}}
  {{other-menus-related-stuff}}
{{/menus}}

I want the close-menu component to be used potentially anywhere in the page markup, and when clicked to trigger some logic within the menus component. There is likely a better approach than communicating only amongst components, however it seems wrong to me to bother controllers and routes with any of this logic. In angular, for example, I would request the "parent" directive and then use it's interface to trigger the menu close.




Aucun commentaire:

Enregistrer un commentaire