When I work the function and code on my Home page, I would like to have the same repeating on all other pages. Note : Copy/paste takes only the design, no code and no function. Can anyone please help me get this done, it’s been a week now :(.
you can easy copy a whole page even to another website in wix.
code and elements will be coppied, only datasets won’t copy to other websites )
kristof.
@volkaertskristof Thank you for your answer. Problem is, I want to copy only the mega menu not the whole page, as this will affect design and content. Or am I seeing something wrong ? Here’s the menu I want to copy.
So your menu bar at the top you want to show on other pages?
You can right click on it and select “show on all pages”
also if you put it on top of the ------- line it will show on all pages aswel.
otherwhise to copy elements you can just copy it, it will hold its name aslong as there is nothing with the same name in the page,
the code you can also just copy if you need it.
or you can add the code to your site code instead of your page code.
I still need to assign the function from the properties manually when I select “show on all pages” e.g “onMouseIn”, “onClick”… And if I tick the respective boxes in properties I need to rewrite the code as it will not consider the code already copied in Site, see picture.
Oke, just to be clear.
You have a mainMenu (where all the pages are under)
and you have a Menu on 1 of those pages wich show/hide some boxes depending on what you click in that menu?
Yes I have a main Menu created with Editor which contains Abous us, Home, and other pages that are hidden. “Products” is a button that is interactive and done with Corvid; when you hove on it or click a second menu pops with “product groups” when you hover on one of these you will have a 3rd menu with the products. See pictures.
Hi @ayadiamne
Instead of using functions linked to the Properties panel, you could use dynamic event handlers.
//Replace those fonctions...
export function myButton_click(event) {
// function
}
//...With those ones
$w("#myButton").onClick( (event) => {
// function
} );
This way you avoid having to link the properties of each element with the code in the editor.
Hope this helps.
@agency Thanks Pascal, So your suggestion is : the code will find where myButton is on each page and associate the function without having the need of linking the code on the button properties ? Is the following code sample right ? :
$w( “#ssButton” ).onClick( (event) {
$w( “#ssBox” ).show();
$w( “#psBox” ).hide();
$w( “#gdBox” ).hide();
$w( “#cBox” ).hide();
$w( “#soBox” ).hide();
$w( “#mrBox” ).hide();
});
@ayadiamne
It could be:
$w("#ssButton").onMouseIn( (event) {
$w("#ssBox").show(); $w("#psBox").hide(); $w("#gdBox").hide();$w("#cBox").hide();$w("#soBox").hide();$w("#mrBox").hide();
});
You can check the Corvid Reference for more information about the onMouseIn() event handler (and other handlers like onClick( ), onDblClick( ), onMouseOut( ), etc.).
@agency This is how I wrote it, doesn’t work, I guess I am writing something wrong. Should it be on the Site coding or Page coding ? Thanks.
@ayadiamne That would be on the page’s code. This is something you will still have to copy and paste into each page’s code, but at least you don’t have to link to every element’s property with the mouse in the editor anymore.
@agency Thank yu very much Pascal, I have only one problem now which is the code is not running and showing that " {" parsing error: unexpected token {. Could you please help ?
@ayadiamne
You can try this:
$w("#ssButton").onMouseIn(event => {
$w("#ssBox").show();
$w("#psBox").hide();
$w("#gdBox").hide();
$w("#cBox").hide();
$w("#soBox").hide();
$w("#mrBox").hide();
});
@agency That was accepted but no reaction on preview.
It is only doing this as you have the line of code on your page already.
As you already have the exact line of code on the page, it is assuming that you are wanting to add a new event handler function, therefore it is giving you a new name of mrButton_mouseIn _1 .
All you need to do is to delete the extra _1 on the end and it will be fine
When you go to the properties panel for the button, simply delete the ‘_1’ it puts on the end of the event function and it won’t add the additional lines of code for it.
Also, with the two Mega Menu examples why not just make it up in your websites header, so they will appear on all pages automatically anyway…
https://www.wix.com/corvid/example/mega-menu
https://support.wix.com/en/article/corvid-tutorial-creating-an-expanding-mega-menu
Also, add the code for the Mega Menu to your site tab and not the page tab, then it won’t matter what page that you add the Mega Menu too as the code will be applied throughout your site.
Worked! Thanks man… It’s for sure better than having to re-write, unfortunately the code @agency gave me didn’t work, otherwise we would have it all done automatically.