page load or url page move is working onItemReady
but button click → page move → not onItemReady
if refresh → working onItem
and not working wixLocation.onChange()
Do not enter the interval.
wixLocation.onChange((location) => {
return loadMegaMenu();
});
$w.onReady( function () {
wixLocation.onChange(() => {
});
return loadMegaMenu();
});
async function loadMegaMenu(){
let allMenusData;
let $item = $w.at();
let containers = $item( “Container” );
containers.forEach( function (container, i, repeatersArray) {
const repeater = container.parent;
const containerChildern = container.children;
const image = containerChildern.filter(element => element.type === ‘$w.Image’ )[ 0 ];
const button = containerChildern.filter(element => element.type === ‘$w.Button’ )[ 0 ];
const text1 = containerChildern.filter(element => element.type === ‘$w.Text’ )[ 0 ];
repeater.onItemReady(($item, itemData, index) => {
console.log( 'in onItemReady ' )
if (itemData.subTitle) {
$item( ‘#’ + text1.id).text = itemData.subTitle;
}
if (itemData.subText) {
if (itemData.subText.length > 0 ){
}
}