Can I call a js method in ui-nav-menu?

I want to add a menu item called Change Design. When it’s clicked, a js method is triggered to call an API, which gets a deep link to theme editor.

But this menu item looks like only supporting the static href. I want to use window.open(URL) to open a new tab. Is it possible? I tried to add a js method but it’s not triggered.

I believe you could just link that link to the current theme in the Theme Editor for the store being viewed, no need for extra JS. Have you tried that?

I want to deep-link to a bundle product or the first product of the currently published theme. If the bundle product exists, preview a specific product template. I can’t find a way to do so without going through the backend

Yeah, you would need to query for those upfront before adding the link to the navigation there. As long as you can fetch/filter/check such data you should be able to piece together a working URL to that for the navigation, without needing to listen for click events.

For example, I have been working on an app that links to the default product template within a selected theme. Adding additional parameters for which product is simple at that point but I will note that the link is not within that navigation.

@RobDukarski is correct here. The ui-nav-menu only accepts anchor tags with static href’s as it’s meant to link to other pages in your app. If you had a deeply nested page to link to, you will need to know the URL upfront and append that to the nav menu.

3 Likes