0

I Built a lightning component which is used in opportunity layout. This component used some child component as lightning tab.

The problem is when I edit and change some value in first tab is not reflecting the second tab I need to refresh the page to see the updated value in second tab.

My question is how to refresh the tab while switching.

my code looks like below:

<aura:component>
    <lightning:tabset selectedTabId="two">
        <lightning:tab label="Item One" id="one">
            <c:child 1>
        </lightning:tab>
        <lightning:tab label="Item Two" id="two">
            <c:child 2>
        </lightning:tab>
        <lightning:tab label="Item Three" id="three">
            <c:child 3>
        </lightning:tab>
    </lightning:tabset>
</aura:component>
  • can you Please update your question where & when exactly you want refresh the Main parent component, based on what you have we asked we need your c:child 1 & c:child 2 logic – sdandamud1 Jun 24 at 12:53
  • let say in child_1 contains detail view of current opportunity record and child_2 to edit some particular field then this changes should reflect immediately in child_1. But now it's not happening. I need to refresh the page to see the changes @sdandamud1 – nubie Jun 25 at 5:04
0

You can try creating the component's directly using JS.

for ex.

//You have to assign an aura:id in order to set a component into the element
<lightning:tab label="Item One" id="one" aura:id="tab-one">
</lightning:tab>

    //get the element to set a child component
    var tab1 = component.find('tab-one');
    //create the child component here
    $A.createComponent(
       "c:child1", {},
        function(childCmp, status, errorMessage){
            if (status === "SUCCESS") {
                //set the child component here
                tab1.set("v.body", [childCmp]);
            }                
        }
    );

Also, you need to to create this component everytime when you switch between tabs.

This approach will always load the component directly into the tab.

  • I which component i need to write this client side js – nubie Jun 24 at 11:10
  • @nubie can you please explain your question? – Tarique Shamim Jun 24 at 11:21
  • let say in child_1 contains detail view of current opportunity record and child_2 to edit some particular field then this changes should reflect immediately in child_1. But now it's not happening. I need to refresh the page to see the changes. @Tarique Shamim – nubie Jun 25 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.