Hi Folks, I have the below code which works but throws an error when executed? What am I missing?
export function dropdown_change(event) {
const max = 8
const min = 1
if (event.target.value === '1') {
for (let i = 2; i <= max; i++)
$w(`#participantbox${i}`).collapse();
}
if (event.target.value === '2') {
for (let y = 2; y > min; y --)
$w(`#participantbox${y}`).expand();
for (let i = 3; i <= max; i++)
$w(`#participantbox${i}`).collapse();
}
if (event.target.value === '3') {
for (let y = 3; y > min; y --)
$w(`#participantbox${y}`).expand();
for (let i = 4; i <= max; i++)
$w(`#participantbox${i}`).collapse();
}
if (event.target.value === '4') {
for (let y = 4; y > min; y --)
$w(`#participantbox${y}`).expand();
for (let i = 5; i <= max; i++)
$w(`#participantbox${i}`).collapse();
}
}
Looks to me like a simple type error in your code lines for your elements expand and collapse functions, with you using an ` instead of just a ' or "
Try simply changing your lines from
$w(`#participantbox${i}`).collapse();
To this
$w('#participantbox${i}').collapse();
See the API reference etc for those functions...
https://www.wix.com/corvid/reference/$w.CollapsedMixin.html
Toggle an element's collapsed state
if( $w("#myElement").collapsed ) { $w("#myElement").expand(); } else { $w("#myElement").collapse(); }