Expand my Community achievements bar.

Include one component in other

Avatar

Level 6

i have a component A.

Now i should create a component B. The requirement is there will be image in Component B. when you click on it ComponentA should pop out

Can some one suggest me efficient way to do it !!!

 

Thanks

3 Replies

Avatar

Level 8

Maybe try something like this

<div class="component-a"> <div class="component-b" data-sly-resource="${'image' @ resourceType='wcm/foundation/components/image'}"> </div> </div> <script type="text/javascript"> (function () { $('.component-a').on('click', function () { //Do something with component-b > img here }); }); </script>

Avatar

Level 6

Hi leeasling 

Will te dialog,html and styling of component A will be included in component B if I use this code?

Avatar

Level 10

Do not this as assume permanent include.

Lets says,

You have two separate component A and component B.

Once you include B in A using code shared above. When ever you get component A on page you will see B will be included in it.

But still Component B will be rendered by it's own resource type and Component A will be rendered by it's own resource type.