1

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?

Shahroon
  • 307
  • 2
  • 15
  • Does that component have an identifier? Something like a specific ID, a specific attribute, or maybe the first/last component in a list? – swastik Aug 28 '15 at 14:28
  • Can you provide a basic code example describing what you are trying to achieve ? Maybe it's a design problem that could be solved differently. – QuantumLicht Aug 28 '15 at 17:15

1 Answers1

2

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')) ....
 })
Kingpin2k
  • 47,277
  • 10
  • 78
  • 96
  • Be mindful of the logic you put in here, because if you set any component property it will cause a rerender. – locks Sep 01 '15 at 11:59
  • Since Glimmer hit the streets, rerendering has become ridiculously cheap and practically a non-issue. http://emberjs.com/blog/2015/06/12/ember-1-13-0-released.html – Kingpin2k Sep 01 '15 at 15:32