I managed to create in-page tabs with custom code, with the help of forum references, by using WIX multi-state box. Coding is not my thing and I am more of a Product Designer. I am trying to custom code a feature, where I come to the page called hobbies and with that particular tab selected based on the button, I click on the home page. For example, if I click on Button3 on the home page, it should redirect me to the Hobbies page with the 3rd tab automatically selected. It would be really kind of you if someone could help me achieve this. Screenshot and tabs code attached for reference.
$w.onReady(function() {
const greyColor = "#E7EBFF"; // For selected tab
const whiteColor = "#FFFFFF"; // For other tabs
const blueColor = "2873F1";
$w('#motionDesigning').onClick(() => {
$w('#HobbiesTab').changeState("motionDesigningState");
});
$w('#writing').onClick(() => {
$w('#HobbiesTab').changeState("writingState");
});
$w('#sketching').onClick(() => {
$w('#HobbiesTab').changeState("sketchingState");
});
$w('#cooking').onClick(() => {
$w('#HobbiesTab').changeState("cookingState");
});
$w('#photography').onClick(() => {
$w('#HobbiesTab').changeState("photographyState");
});
$w('#birdWatching').onClick(() => {
$w('#HobbiesTab').changeState("birdWatchingState");
});
$w("#HobbiesTab").onChange((event) => {
const buttonNames = ["motionDesigning", "writing", "sketching", "cooking", "photography", "birdWatching"];
buttonNames.forEach(buttonName => {
let button = $w("#" + buttonName); // e.g. $w("#motionDesigningbutton")
let state = buttonName + "State"; // e.g. motionDesigningState
if (event.target.currentState.id === state) {
button.style.backgroundColor = greyColor;
button.style.textcolor = blueColor;
} else {
button.style.backgroundColor = whiteColor;
}
});
});
});