Dear people, I am trying so hard the past 1 week to follow this tutorial → Velo Tutorial: Creating an Expanding Mega Menu | Help Center | Wix.com.
At the end of it it says:
function setSubSubMenu (repeaterData) { //Set the image of the Submenu 1
$w(‘#image1’).src = repeaterData.img1;
for ( let i = 1; i <= subLevel2RepeaterCount; i++)
{ //Convert the Submenu 2 string to a Javascript object.
const dataSubSub = JSON.parse(repeaterData[subSubItems ${i}
]);
//Set a unique ID for each item.
dataSubSub.forEach(subSubItem => { subSubItem._id = createUniqueId(); })
//Set the Submenu 2 data in the repeater.
$w(#repeaterSubSub ${i}
).data = dataSubSub;
} }
Which for me as I understand it, on the JSON.parse function it gets from the collections the whole column named subSubItems1-2-3-4-5 and saves all the subSubItems1 data to dataSubSub and then giving all those data to the first repeater , then for the second subSubItems2 to the 2nd repeater etc.
For me thought I have tried the same thing and on the parse I’m getting unexpected symbol on line 77 and ONLY works for me if i do an iteration-> repeaterData[i][j] for each individual piece which then thought causes the repeaters to have only 1 item registered as follows.
How do they get the entire subSubItems1 column from the database ? I am not very accustomed to JavaScript but to me is really hard to achieve this.
My site is https://giannisliko.wixsite.com/my-site-1 and the function that im trying to fix is:
I tried creating an array called result so I could do JSON.parse(result[i]) but still I am getting the same error Unexpected symbol at line 77.
Any help is greatly appreciated.
function setSubSubMenu ( repeaterData ) {
//Set the image of the Submenu 1
//$w(‘#rangeMenuImage’).src = repeaterData.img1;
const arr = repeaterData . filter ( item => item );
//var col = arr.map(function(value,index) { return value[1]; });
//console.log("the filtered sub are: " , arr[subSubItems1
]);
//console.log("sub1 is ", arr);
//results containing only subSubItems${i}
const result = ;
const result1 = repeaterData . map ( function ( a ) { return a.subSubItems1 ;}). filter ( item => item );
const result2 = repeaterData . map ( function ( a ) { return a.subSubItems2 ;}). filter ( item => item );
const result3 = repeaterData . map ( function ( a ) { return a.subSubItems3 ;}). filter ( item => item );
var result4 = arr . map ( function ( a ) { return a.subSubItems4 ;}). filter ( item => item );
var result5 = arr . map ( function ( a ) { return a.subSubItems5 ;}). filter ( item => item );
result . push ( result1,result2,result3 );
for ( let i = 0 ; i < 3 ; i ++) {
for ( let j = 0 ; j < 5 ; j ++){
//console.log(eval(result${i}
));
const dataSubSub = JSON . parse ( result[i ][ j ]);
dataSubSub . forEach ( subSubItem => {
subSubItem._id = createUniqueId ();
})
//Set the Submenu 2 data in the repeater.
$w ( #repeaterSubSub ${ j }
). data = dataSubSub ;
}
}