jeudi 2 avril 2015

Sending an action to containing component

If I have two components:



  • nav-menu

  • nav-button


and nav-menu is a block component that would contain nav-button like so:



{{#nav-menu}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
{{nav-button}}
{{/nav-menu}}


I'd like the button to be able to directly send an action to the menu to tell it to toggle it's visibility state. I guess if I hook into a mutux point in Controller then I could do something like:



{{#nav-menu toggleNavigation=mutex}}
{{nav-button action=mutex}}
{{/nav-menu}}


Is this the only way? Just looking for the most graceful, ember-centric way of doing this.





Aucun commentaire:

Enregistrer un commentaire