Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js {{action}} in {{each}}

Tags:

ember.js

Say I have the following template

{{#each item in controller}}
    <a {{action "doSomething" item}}>{{item.name}}</a>
{{/each}}

Now I have the following action defined in the router.

doSomething: function(router, event){
    event.context.get('name');
}

is there anything wrong with accessing the property this way? I'm just asking because I haven't seen this anywhere else.

like image 390
Ilia Choly Avatar asked Dec 01 '25 09:12

Ilia Choly


1 Answers

There's nothing at all wrong with doing that. That's the purpose of the context.

like image 144
Luke Melia Avatar answered Dec 04 '25 10:12

Luke Melia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!