I am creating a file menu like this using Ember:
{{file-menu menuItems=model.fileMenu.menuItems}}
file-menu.hbs:
<ul class="nav navbar-nav">
{{#each menuItems as |item|}}
{{component item.type item=item}}
{{/each}}
</ul>
Then in my router I am constructing the menu like so:
var fileMenu = FileMenu.create();
var orderButton = MenuButton.create({name:"Place Order"});
var fileMenuItem = MenuItem.create({name:"File"});
fileMenuItem.addSubItem(MenuItem.create({name:"Save"}));
fileMenuItem.addSubItem(MenuItem.create({name:"Load"}));
fileMenu.addMenuItem(fileMenuItem);
fileMenu.addMenuItem(MenuItem.create({name:"Edit"}));
fileMenu.addMenuItem(MenuItem.create({name:"Help"}));
fileMenu.addMenuItem(MenuButton.create(orderButton);
Now I want to programmatically add an action to my orderButton for when it is clicked. However, I am not sure how to do this. I could only find info on doing it from the template. Is it possible to add actions programmatically and is it acceptable to do that?
Aucun commentaire:
Enregistrer un commentaire