I have a list made out of a repeater on a dynamic page with a menu over it with 7 button.
I want my button to act like a menu.
When i click one ive made a code that sort the column under it, but i would like the button to turn green too and stay like that until another button is clicked for a different sort (then it would come back gray)
And i would like to have example the ‘date’ button green by default, it is the opening sort when you open the index.
Hi,
Lets say that you wish the button to turn green once clicked. You can locate a green button on top of each brown button and set them to be hidden on load . Once a brown button is clicked, you can hide the brown button and show the green button instead. You can do that by using the onClick event.
When i will have clicked lets say one of the gray button and the hidden one will have appear, how it is gonna return gray when i will select another gray one?, whatever wich one of the 7.
Just hide it
I’ll just go with a general skeleton code, and assume the green buttons are called ‘menuButtonGreen1’, '‘menuButtonGreen2’ …:
function highlightRelevantButton(selectedButtonIndex) {
const numberOfButtons = 10;
for (let i = 1; i < numberOfButtons; i++) {
if (i === selectedButtonIndex) {
$w(`menuButtonGreen${i}`).show();
} else {
$w(`menuButtonGreen${i}`).hide();
}
}
}
Hey liran, when you say, “every time i switch a page” , do you assume that each time i click one of my button i go to a different page?
Because it’s actually just sorting the list below, there is one page only.
Humm Uval, i dont think we talk about the same thing, me it’s 7 separate buttons that sort the list below them, that i want to act like a menu (the one i clicked to sort lets say “age” , i want it to change color so it’s in ‘clicked’ state, then return to its original color once another button is clicked.
hey guyz i found a another way to highlight the clicked button using invisible box above the like button and by using the disable option in liked button to highlight.
this is the code (please note that i am not a coder XD)
export function repeater1_itemReady($w, itemData, index) {
$w(“#Like”).onClick( () => {
if ($w(“#Like”).label === “Like”){
$w(“#Like”).label = “Liked”;
$w(“#Like”).disable();
//highlight this disable button as you want
$w(“#box2”).show();
//choose hidden on load on box2
} else {
$w(“#Like”).label = “Like”;
}
});
}
//place the invisible box above the like button
export function box2_click(event, $w) {
$w(“#Like”).enable();
$w(“#Like”).label = “Like”;
$w(“#box2”).hide();
}