shabunc
shabunc

Reputation: 24741

How can I find the closest parent component?

An ExtJS component (let it be component A) is rendered to some DOM element. This DOM element itself later is used like contentEl for some other EXtJS component (componentB).

What is the simplest way to find out that componentA is rendered for some element which is, in turn, used by some componentB. To put it simple, is there something like jquery's closest, but as we have components instead of DOM elements?

UPD: I know about so called ComponentQuery language and the up method, I have a strong feeling that solution is somewhere close to, but I just can't figure out, how exactly it can be done. The problem with 'up' method is, as far as I can understand, it actually test chain of directly declared ancestors. By "directly directed" I mean each new component has been inserted directly as child to its parent. In my case, this chain is broken.

Upvotes: 0

Views: 3315

Answers (1)

Rene Saarsoo
Rene Saarsoo

Reputation: 13917

I feel you have to fall back to DomQuery and simply check if the DOM node contains a div with a classname that your suspected component is supposed to generate. It's a hack, but what you are doing looks also like a hack.

Maybe you can structure your things differently, so that the child components somehow register themselves with the parent. Hard to suggest much without knowing the particulars.

Upvotes: 2

Related Questions