Hi I created widgets in the branded app and used the slider repeater. Im trying to use the code assist to open up the screens that these 4 cards are supposed to open to. the id’s are correct but im not sure where im going wrong.
This is the full code im using.
import wixNavigateMobile from 'wix-navigate-mobile';
$w.onReady(() => {
const rep = $w('#repeater1'); // your repeater id
const pickScreen = (txt) => {
const t = (txt || '').toLowerCase();
if (t.includes('society')) return 'society';
if (t.includes('tennis')) return 'tennis';
if (t.includes('equestrian')) return 'equestrian';
if (t.includes('motorsport')) return 'motorsport';
return '';
};
rep.onItemReady(($item, itemData, index) => {
// 1) read a visible title from this card
let title = '';
['#text5', '#text7', '#text3', '#text2', '#text1'].some(sel => {
try {
const el = $item(sel);
if (el && el.text) {
title = el.text;
return true;
}
} catch (_) {}
return false;
});
// 2) decide screen by title, fallback to position if needed
let screen = pickScreen(title);
if (!screen) {
const byIndex = ['society', 'tennis', 'equestrian', 'motorsport']; // left-to-right
screen = byIndex[index] || '';
}
if (!screen) return;
// 3) wire the arrow button in THIS card
const arrow = $item('#button2'); // your arrow id
if (!arrow) return;
const go = () => wixNavigateMobile.toScreen(screen)
.catch(err => console.log('Navigation error:', err));
if (typeof arrow.onPress === 'function') arrow.onPress(go);
else if (typeof arrow.onTap === 'function') arrow.onTap(go);
else if (typeof arrow.onClick === 'function') arrow.onClick(go);
});
});
