anish samant
anish samant

Reputation: 193

Call a method on switching between lightning tabs in salesforce using LWC

I have 3 lightning tabs. I want to run a particular piece of code on switching between these tabs. Is there a way I can do it. I tried writing the code in renderedCallback and connectedCallback, but none of these methods are called on switching between tabs.

Upvotes: 1

Views: 7936

Answers (1)

mSinisa
mSinisa

Reputation: 3

You could add onactive in your markup

   <lightning-tabset active-tab-value={activeTab}>
<lightning-tab label="Item One" onactive={handleClick} value="one">
  One Content !
</lightning-tab>
<lightning-tab label="Item Two" onactive={handleClick} value="two">
  Two Content !
</lightning-tab>
<lightning-tab label="Item Three" onactive={handleCLick} value="three">
  Three Content !
</lightning-tab>

Upvotes: 0

Related Questions