How to trigger javascript function when I click on the close button at tab?

Hi, I have a question on showCloseButton property. 
I would like to trigger a javascript function when I clicked on the Close button on the tab, is there any way I can do it?

Thank you




3 Replies 1 reply marked as answer

NR Nevitha Ravi Syncfusion Team November 19, 2020 06:53 AM UTC

Hi Weng, 

Greetings from Syncfusion Support. 

We can trigger a function when a tab item is closed by invoking removed event. Please refer to the following code and sample. 


<ejs-tab id="appTab" showCloseButton="true" removed="onTabRemoved"> 
…. 
</ejs-tab> 
<script> 
    function onTabRemoved(args) { 
        console.log("Removed tab index:" + args.removedIndex); 
    } 
</scrip 


Regards, 
Nevitha 


Marked as answer

WK Weng Keong Lan November 20, 2020 01:06 AM UTC

Hi, thanks for your assistance and it worked well!


NR Nevitha Ravi Syncfusion Team November 20, 2020 03:45 AM UTC

Hi Weng, 

You are most welcome 😊, please get back to us for further assistance. 

Regards, 
Nevitha 


Loader.
Up arrow icon