Shahroon
Shahroon

Reputation: 307

didInsertElement for only single element EmberJs

I want to call didInsertElement on just one element but not on others, I have a component template with multiple elements, but I just want to use it on specific element.

Any Idea how to do this? Is it possible, if yes, good practice or not..and component having multiple elements pointing towards other components, is that okay?

Upvotes: 1

Views: 104

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Assuming I'm understanding you correctly and you want to call didinsertelement on one instance of a component, but not on the other instances of the component.

With that assumption the simplest approach would be to pass in some parameter to the component that states whether or not to execute the logic handled in the didinsertelement.

{{some-comp dologic='false'}}

 setup: Ember.on ('didInsertElement', function (){ 
    if (this.get ('dologic')) ....
 })

Upvotes: 2

Related Questions