Update with a solution in case anyone else has this issue
This post can be closed.
Why the Error?
The MegaMenu editable Corvid example (linked below) on wix.com has this statement in the OnReady variables
let $item = $w.at();
the variable is useful for at(event.context) code, but throws errors when used for non events in the functions forEach() or forItems() that refer to $item.
Solution
Replace the initial onReady variable with this
let $item = $w;
Then systematically go through your code and adjust any $item used in the context of an event handler to include the correct syntax. An example:
The original code includes a function for a click on any of the buttons, followed by a switch statement to identify the button.
$item('#' + button.id).onClick((event) => {
switch (button.id) {
case 'mainMenuButton':
button.style.backgroundColor = '#7DC443';
$item('#' + button.id).style.backgroundColor = '#e1ebc9';
$item('#' + button.id).style.color = '#182310';
break;
Replace this code with something like the following, and don’t forget also to adjust submenu which is directly below this code.
Note in some cases, you can make your variable changes at the top of a code block, like this. In others, you’ll need to define it separately for each function.
I advise not to solving this with global variables - context caused the problem.
$item('#' + button.id).onClick((event) => {
let $Item = $item.at(event.context);
switch (button.id) {
case 'mainMenuButton':
button.style.backgroundColor = '#7DC443';
$Item('#' + button.id).style.backgroundColor = '#e1ebc9';
$Item('#' + button.id).style
break;
(If you wish to honour camelCase don’t copy my horrible cut and paste i → I solution - because you’ll realise when writing it up that people might not spot the bold capitalised I is what changed).
After you’ve replaced all your events the menu should work perfectly.
And the only mystery is how the heck it worked originally!
Good luck.
Hi folks, I have a heavily customised version of the standard Wix Mega Menuon my site. So when it messed up recently I assumed I was the cause. TypeError, Component Scope - I’d badly introduced a new component somehow.
After 3 days of failing to find out how I’d made a mistake, I went back to the example.
The Wix hosted example works just fine, no errors.
But choose edit then save and publish the code example, you’ll get this and you’ll find the same errors thrown as I was seeing on my customised version.
I’m not asking for a solution, though if anyone has one that would be wonderful.
The advice I’d like is to where to route a request - for something that seems to be a bug within a corvid example?
-
Is it customer services?
-
Or one of the Wix Corvid Masters?
-
Or is this a general repeater bug that just happens to show in this example?
Thank you
M
(Update - note this TypeError only happens on the live site, sandbox works fine).