- I have a page built in Wix Studio Editor with a CMS collection containing 4 entries.
- On this page, I have:
A video player that should display a video URL from the CMS collection.
A description box (text element) that should display a description from the CMS collection.
A repeater that displays 4 sections (corresponding to the 4 entries in your CMS collection). - Inside each repeater section, there are two buttons:
When either button in a repeater section is clicked, it should update:
The video player with the appropriate video URL from that particular CMS entry.
The description box with the corresponding description from that same CMS entry.
I want it to:
When a button is clicked (inside any repeater section), the video player should play the video associated with that repeater item, and the description box should update with the appropriate description for that video.
The updates are specific to the content (video and description) of the clicked repeater section.
I’ve tried using flexiboxes, pro galleries, containers inside cells, and now I’ve using a cell divided format to hold each of these elements. What’s wrong with my current code? Maybe field keys? Or would it have something to do with the current CMS connections I have in place (I’m certain are correct). ( Also I input my correct item names).
$w.onReady(function () {
// Make sure the repeater is connected and ready
$w(“#yourRepeaterID”).onItemReady(($item, itemData, index) => {
// Handle the first button click
$item(“#button1ID”).onClick(() => {
// Update the video player source and description dynamically
$w(“#videoPlayerID”).src = itemData.videoField; // Link to the correct video URL field
$w(“#descriptionBoxID”).text = itemData.descriptionField; // Link to the correct description field
});
// Handle the second button click
$item("#button2ID").onClick(() => {
// Update the video player source and description dynamically
$w("#videoPlayerID").src = itemData.videoField; // Link to the correct video URL field
$w("#descriptionBoxID").text = itemData.descriptionField; // Link to the correct description field
});
});
});