Lets say I want to have 1 click event do different things (dependent on the name/value of the clicked element)
I’ve got a repeater w/ a button… The button labels are something like ‘Box 1, Box 2, Box 3…’ (from the data collection)… Elsewhere on the page there are several sequentially named boxes (‘Box1, Box2, Box3…’)
The idea is, if someone clicks on a button with the label “Box 1” it will expand an element named “Box 1” somewhere else on the page. If someone clicks on a button with the label “Box 2”, it would expand an element named “Box 2”… … etc.
I think I’ve been staring at this too long to think of it objectively anymore. Any suggestions? Am I even a little close?
let btnArr = $w("Button");
$w("#repeater2").onItemReady( ($item, itemData, index) => {
btnArr.forEach(btn => {
btn.onClick((event, $item) => {
var $item= event.target.label
var $item2 = $item.replace(" ", "") //remove spaces
var $action = "$w('#" + $item2 + "')"
$action.expand();
});
});
})