Mon. - Fri. 9 am - 5 pm Support Policy
Remember me

Menu Item to a page with certain tab open

4 months 1 week ago #1

  • Renato's Avatar
  • Renato
  • Posts: 80
Hi, I have a website with some pages. Each page has a "Tab" item with a few tabs each.

I want to link menu items to these tabs.

Using the code:
jQuery(document).ready(function(){
    jQuery('.example').on('click', function(){
        event.preventDefault();
        jQuery('[href="tab-1547605288749"]').trigger('click');
    })
})

I'm able to create buttons that opens the tabs, but it's not what I need.

I already tried to add a menu item with External URL pointing to /page#tab-xxxxx and /page/#tab-xxxx but without success... Can you help me clarifying what should I do in this case?

Thanks!

The website is novo.csamro.com.br/novo/ (only the parent menu items are working because i need to figure out this tab thing)

4 months 1 week ago #2

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 6298
Hello,

You need to use this code.
var tabsLink = window.location.hash
document.addEventListener('DOMContentLoaded', function(){
 var a = document.querySelector('a[href="'+tabsLink+'"][data-toggle="tab"]');
 if (a) {
  a.click();
 }
})
You need to replace the menu links
to link to this page + tab hash.

Example:
novo.csamro.com.br/novo/componentscsa#tab-15466944287452

Regards,
Vyacheslav, Balbooa.com

4 months 1 week ago #3

  • Renato's Avatar
  • Renato
  • Posts: 80
It works!! Thanks!!!!

4 months 1 week ago #4

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 6298
You are welcome ;)

2 months 1 week ago #5

  • Renato's Avatar
  • Renato
  • Posts: 80
Vyacheslav, one thing that is happening also is that:
1. It goes to the anchor, and I need it to stay at the begining of the page
2. When I'm already at one page and select on the top menu another submenu of the same page, it changes the browser URL but don't change to the tab.
Use-case example:
a. After opening www.csamro.com.br the user clicks "Services -> Test Cell"
b. Now he hovers the topmenu on "Services" and click "ECTM"
c. The URL changes, but nothing changes on the page.

I know It's clear for us that the tab is there, he don't need to use the top menu again, but my client is afraid his clients won't be "so smart"...

Any ideas?

2 months 1 week ago #6

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 6298
Hello,
Thank you for contacting us

Specify what result is needed.
Do you need the url to change when switching tabs?

Regards,
Vyacheslav, Balbooa.com

2 months 1 week ago #7

  • Renato's Avatar
  • Renato
  • Posts: 80
The final result would be:

When clicking to the menu item related to a tab
- load the page with the correct tab opened (working)
- load the page at the top, don't scroll to the tab like when linking to anchors
- if clicking again on the menu at an item related to the same page that is open, but another tab: reload the same page and open the other tab

Thanks for the help!

1 month 3 weeks ago #8

  • Renato's Avatar
  • Renato
  • Posts: 80
Any ideas?

1 month 3 weeks ago #9

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 6298
Hello,
Thank you for contacting us
Unfortunately there is no such possibility.

Regards,
Vyacheslav, Balbooa.com
Powered by Kunena Forum