I have a repeater that acts as a video playlist selector.
I have attached a box to each item in the repeater that I would like to be able to change background color depending on what video source is in the video player.
That way, a viewer would know which video on the playlist they are currently watching.
It is not as easy as you think, but of course it is possible.
You have to loop through all the repeater searching for the item that have the same source as the current displayed video. It would be something like this:
The other problem I see with this that I’ve been struggling with, is that of course I can get the box in the repeater to change the background color with a simple onClick, but once the color is changed, it doesn’t change back like the Wix Learn example.
If anybody knows who worked on the Wix Learn pages, it would be extremely helpful for me to get in touch with them, becasue those are the exact features I’m looking for in order to launch my courses page!
That would be great! For now I’ve gotten this code below to work, but it’s only relevant to clicking and doesn’t necessarily work 100% as intended. If you have time, I’d love to see the syntax you’re thinking because I’ve tried 20-30 different things that all failed haha… cheers!
let selectedRecord;
$w.onReady(function () {
handleSelectItem();
function handleSelectItem() {
$w("#box1").onClick((event, $w) => {
if (selectedRecord) {
selectedRecord.style.backgroundColor = "#ffffff"; //reset previously select record
}
let $item = $w.at(event.context); //get scoped selector
selectedRecord = $item("#box1");
selectedRecord.style.backgroundColor = "#ffcc37"; //highlight newly selected one
});}})