XYZ
XYZ

Reputation: 27397

How to handle event action on the whole component?

I can bind an action to a table's row using {{action "foo"}}; However, I converted each row into a component becase I need to encausulate some states inside each row.

How can I handle the default click event for the entire component in Ember way?

I am sure I can do the event binding in didInsertElement hook, but I am not sure this is the correct way to do so, or anti-Ember.

Upvotes: 0

Views: 33

Answers (1)

roger
roger

Reputation: 1141

Try this out in your component:

import Ember from 'ember';

export default Ember.Component.extend({
  click() {
    // do stuff
  }
});

Documentation: https://guides.emberjs.com/v2.11.0/components/handling-events/

Upvotes: 1

Related Questions