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
Rajat Mahajan 28Rajat Mahajan 28 

Lightning Tab Attributes do not get set from Server side during the page load (via doInit function)

Dear All

I have a requirement where i need to set lightning tab attributes on page load , this somehow does not work when i get these attributes from server side call

Consider this snippet:
<!--
Name   : PinUnpin.cmp
Author : Rajat Mahajan
Date   : 24th April, 2018
Desc   : This component will showcase the pin unpin functionality on account button click
-->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="GLOBAL" controller="PinUnpinController">
    <!-- Style sheet LDS -->
    <ltng:require styles="{!$Resource.SDLS252 + '/styles/salesforce-lightning-design-system.css'}"/>
    
    <!-- Tabset variables -->
    <aura:attribute name="tabNameList" type="Map" />
    <aura:attribute name="moretabs" type="Aura.Component[]"/>
    <aura:attribute name="selTabId" type="String" />
    
    <!-- Default tab variables -->
    <aura:attribute name="defaultTabLabel" type="String" default="test"/>
    <aura:attribute name="defaultTabID" type="Integer" default="test"/>
    
    <!-- Call the int method -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
 
    <!-- Lightning Tab set -->
    <lightning:tabset aura:id="tabs" variant="scoped" selectedTabId="{!v.selTabId}" >
        <div style="display:block">
            <lightning:tab aura:id="defaultTabAuraID" label="{!v.defaultTabLabel}" id="{!v.defaultTabID}" >
                {!v.body}
            </lightning:tab>
        </div> 
        {!v.moretabs}   
    </lightning:tabset>
</aura:component>

now my doInit here sets the defaultTabLabel and defaultTabID correctly when i set them from JS Controller directly, but whenever i make server side (Apex) calls from the doInit method, the attributes get set on cmp but do not get set in the lightning tab for some reason. 

I believe there is something in the rendering lifecycle that is giving me this problem. I tried to use javascript promise functions also, but was of no help

Has anyone else encountered this problem?

Thanks for your help in advance!
GhanshyamChoudhariGhanshyamChoudhari
you may try setTimeout function in doinit 

sample 
 
doInit : function(component, event, helper) {
        var device = $A.get("$Browser.formFactor");
        if(device == "DESKTOP"){
            setTimeout(function(){              
         //call helper here or write logic here                  
                }            
            }, 5000);           
        }else{
          //else Mobile logic  here 
        }   
    },