function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Himanshu DangwalHimanshu Dangwal 

Issue in dynamically rendering nested components!!

Hello All pro developers,

Case:
I am a nested component tree structure by dynamically rendering components. To create component I used below default method (Aura):
$A.createComponent( type, params, callback );

Structure to achive:

parentA.cmp
|----AChildLvL1.cmp
|    |------ALvL1SubChild1.cmp
|    |------ALvL1SubChild2.cmp
|----BChildLvL2.cmp
|    |------BLvL2SubChild1.cmp
|    |------BLvL2SubChild2.cmp

In above patern I am dynamically create component AChildLvL1.cmp/BChildLvL2.cmp and based on further condition their child component are being rendered.

Problem: 

Component is not able to render dynamically. in below conditions:
1. In lightning add builder view it is not able to render dynamically. 
2. Same is being replicating whenever I am pushing same code in my unmanaged package and installing it in different org. 
        After installing package I'm facing same issue.

Please let me know if anyone is aware of the reason, any help would be appreciated.


Regards-
Himanshu Dangwal





 

Best Answer chosen by Himanshu Dangwal
Vivek.GuptaVivek.Gupta
@himanshu,
If you are creating a package then call your component with packaging org namespace like namespace: component instead of c: component.

If it works for you then choose my answer as the best answer.
 
Thanks 
Vivek Gupta

All Answers

Deepali KulshresthaDeepali Kulshrestha
Hi Himanshu,

Greetings to you!

You must empty the body of the previously created component to create another component dynamically.
cmp.set("v.body",[]);
After that you can call the $A.createComponent( type, params, callback );

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Himanshu DangwalHimanshu Dangwal
Hey @deepali,

Thank you for your answer, but this solution is not working. 

Let me update my query:
> I am using managed package, with namespace eg: test_

if you are aware then please do let me know.

Regards-
Himanshu Dangwal
Vivek.GuptaVivek.Gupta
@himanshu,
If you are creating a package then call your component with packaging org namespace like namespace: component instead of c: component.

If it works for you then choose my answer as the best answer.
 
Thanks 
Vivek Gupta
This was selected as the best answer