Hello, I would like to create an onClick event on one of the buttons in my nav bar, but the properties panel only shows the ID for the whole bar - 'horizonalMenu1'.
How can I create an onClick event for one button only?
Here is the broader context.
- user clicks on button in nav bar
- code checks a condition in the database against that userID
- if condition is not met, user is sent to an alternative url, rather than the one linked in the nav bar
Thank you.
Hi,
You can add this event handler, and at the handler write the condition, but its still not going to
impact the Menu Tab Spacing.
As long as you add this menu, any member can reach to any page without a condition.
Best,
Sapir
Thank you Sapir. I tried that too, unfortunately the mobile site becomes really impractical. I don't know how (or if) I could then convert each individual button into the nice 1-icon nav bar that is automatically created on the mobile version of the site.
I was exploring the option on a onAfterSave, so that as soon as the user logs in, I could perform the database check and proceed accordingly.
Do you think that would work?
Hi,
I suggest you to create your own menu bar and add for each button an onClick() event handler.
At the handler write your condition or just use the wixLocation.to()function to reach to another URL page.
Best,
Sapir
Thank you for your input Sapir.
I tried that, but it creates confusion with the nav bar pages.
Is there a way to write code that says something like, "if URL being called is 'x', then do 'y'"?
Hi,
There is no API for Horizontal Menu Tab Spacing.
Instead you can add a external button to your site's header and add an OnClick() event.
Best of luck!
Sapir