Programmatically change active Tab
Hi, I'm trying to change the active tab of the tabs form component.
I'm using this code to trigger a traditional html click event when a checkbox is ticked.
Is there a better way to do this? I tried things like setting the 'activeTab' but it didn't work.
TYIA
if ($state) {
$this->js("function clickGuardianTab() {
var guardianTabButton = Array.from(document.querySelectorAll('button[role="tab"]')).find(btn => btn.textContent.trim().toLowerCase() === 'guardian');
guardianTabButton.click();
}");
}
I'm using this code to trigger a traditional html click event when a checkbox is ticked.
Is there a better way to do this? I tried things like setting the 'activeTab' but it didn't work.
TYIA
if ($state) {
$this->js("function clickGuardianTab() {
var guardianTabButton = Array.from(document.querySelectorAll('button[role="tab"]')).find(btn => btn.textContent.trim().toLowerCase() === 'guardian');
guardianTabButton.click();
}");
}
