• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to add navtab with id to add-on

Dadparvar

Well-known member
#1
Hi,

My add-on has a push menu, that when you click on something with "baseexpand" id, menu comes out.

I added this tab to navigation:
Code:
<li style="cursor: pointer" id="baseexpand" class="navTab PopupClosed"><a class="navLink">TAB LABEL</a></li>
And it works.

But I want to add it using code event listener. This is my php code:
Code:
$extraTabs['baseexpand'] = array(
            'title' => 'Push Menu',
            'href' => XenForo_Link::buildPublicLink('#XenForo'),
            'selected' => ($selectedTabId == 'baseexpand'),
            'linksTemplate' => 'dad_pushmenu_Navtabs',
      'position' => 'end'
        );
It adds the navtab, but when I click on it, push menu doesn't come out.

Any opinion on how to reach that goal will be appreciated
 

Chris D

XenForo developer
Staff member
#2
Each tab automatically has a unique class name, in your case it will be "baseexpand".

Assuming that you have some JS code somewhere that is doing something like this:
Code:
$('#baseexpand').something();
You'd just need to update it so it looks like this:
Code:
$('.navTab.baseexpand').something();
 

Dadparvar

Well-known member
#3
Each tab automatically has a unique class name, in your case it will be "baseexpand".

Assuming that you have some JS code somewhere that is doing something like this:
Code:
$('#baseexpand').something();
You'd just need to update it so it looks like this:
Code:
$('.navTab.baseexpand').something();
it works.
But there is a problem.
when I click on it, although push menu starts coming out, but the page also starts reloading. Because that tab behaves like a link. How to disable such functionality?
 

Dadparvar

Well-known member
#4
I mean, now the created navtab is like this:
Code:
<a href="index.php?/" class="navLink">Push Menu</a>
So that when I click it, it load the page.
If it was like this:
Code:
<a  class="navLink">Push Menu</a>
Menu would working fine.
Or in any way, the link doesn't load the page and just be clicked.
 

Dadparvar

Well-known member
#6
Set the href to "javascript:"
Weird!
I set it to :
Code:
'href' => XenForo_Link::buildPublicLink('javascript:'),
But when I click it, it goes to:
Code:
http://localhost/xenforo/index.php?javascript:/
and so:
Code:
Route javascript:/ could not be found.