Are site-wide functions limited? Function from the site code generates to the page code

I have set two catch-all export functions for my custom “menu” buttons for convenience. One for mouseIn , and another for mouseOut . Each mouseIn 's are assigned for my custom-made button menu and so on. I have three menu buttons assigned to this mouseOut function but when I assign this same mouseOut to my next menu button, it created a function of the same name in the page tab, ovveriding the mouseOut in my site tab code.

Below are the two functions I placed in the site tab code .

export function menu_mouseIn(event) {
 if (selectedMenuId.length === 0) selectedMenuId = event.target.id;
 if (selectedMenuId !== event.target.id) {
   let sId = "#sub"+selectedMenuId;
        $w(sId).hide("fade", fadeOptions);
 }
 let id = "#sub" + event.target.id;
 $w(id).show("fade", fadeOptions);
}

export function subMenu_mouseOut(event) {
 let id = "#" + event.target.id;
 $w(id).hide("fade", fadeOptions);
}

The same function name that generates in the page tab code

export function subMenu_mouseOut(event) {
 //Add your code for this event here: 
}
1 Like

Hey,

Please try the following:

  • Remove the code from the page tab

  • Remove the event from the properties panel.

  • Open site code tab

  • Add the event through the properties panel

  • Move the relevant code inside the event

If the function is duplicated again please contact support with the name of the site, description of issue, a screencast of the steps you are doing that results in the function duplication and a link to this forum post.

As a workaround you can also create your own function and type out the onMouseOut() function code manually on the site tab (make sure to also delete the onMouseOut() from the properties panel).

To type out the code manually it would look like this (you can name the function whatever you want);

function functionName() {
$w("subMenu").onMouseOut((event)=>{
let id = "#" + event.target.id;
 $w(id).hide("fade", fadeOptions);
})
}

You will also have to call for this function after you create it within your onReady. Calling the function will look like this:

$w.onReady(function () {
functionName()

});

Hope this helps!

Dara | Corvid Team

Thanks @darak . The workaround does it.