return ( <div className="control-pane"> <div className="control-section tab-control-section"> <TabComponent heightAdjustMode="Auto" id="defaultTab" ref={tab => (this.tabInstance = tab)} created={this.tabCreated.bind(this)} > <TabItemsDirective> <TabItemDirective header={headertext[0]} content={tabContent1} /> <TabItemDirective header={headertext[1]} content={tabContent2} /> <TabItemDirective header={headertext[2]} content={tabContent3} /> </TabItemsDirective> </TabComponent> </div> </div> ); tabCreated() { var tab = document.querySelector("#defaultTab .e-tab-header"); tab.addEventListener("click", this.onClick.bind(this)); } onClick(event) { console.log(event); } |
<button
onClick={() => { this.tabInstance.refresh(); var tab = document.querySelector("#defaultTab .e-tab-header"); tab.addEventListener("click", this.onClick.bind(this)); }} > refresh tab </button> |
Hello Syncfusion,
Can we get name of the Tab onClick() event.
Thanks
Yogesh
Yogesh, You can get the clicked tab name with the help of the code highlighted in the below code snippet.
Sample: https://stackblitz.com/edit/ej2-react-tab-get-clicked-tab-header-name-sample?file=index.js
[index.js]
onClick(event) { if (event) { var target = event.target.closest('.e-toolbar-item'); // Checking whether the clicked item is a tab header item or not if (target) { // If the clicked item is a tab header getting the name using the innerText property alert(target.innerText); } } } |