You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

How to open a tab with a link? Created Nov 2, 2009

This thread is solved

Views: 6636     Replies: 10     Last reply Sep 3, 2010  
You must login first before you can use this feature

sijis

Posts: 4

Registered:
Nov 2, 2009

How to open a tab with a link?

Posted: Nov 2, 2009

Hi all,

I'm having trouble understanding how to create a link that will open a specified tab.

Following the code provided in the demo http://flowplayer.org/tools/demos/tabs/index.html) and this is what I have.


<!-- the tabs --> 
<ul class="tabs"> 
    <li><a href="#tab1">Tab 1</a></li> 
    <li><a href="#tab2">Tab 2</a></li> 
    <li><a href="#tab3">Tab 3</a></li> 
</ul> 
 
<!-- tab "panes" --> 
<div class="panes"> 
    <div>First tab content. Tab contents are called "panes"</div> 
    <div>Second tab content</div> 
    <div>Third tab content</div> 
</div>

When i create a link to #tab2 like

<a href="#tab">link</a>

the tab2 isn't selected, unless i use the full url (eghttp://example.com/#tab2).

Would someone be able to provide me an example on how to make this possible?

Thanks.

sijis

Posts: 4

Registered:
Nov 2, 2009

» How to open a tab with a link?

Posted: Nov 6, 2009

Reply to: How to open a tab with a link?, from sijis
I found that if you enable the history plugin, if you just use the link to the anchor, it works.

PixeL
From Russia with love ;)

Posts: 4

Registered:
Nov 8, 2009

» How to open a tab with a link?

Posted: Nov 8, 2009

Reply to: How to open a tab with a link?, from sijis
I had this problem too, but i think i have a solution:
- Take a source code of tools.tabs-1.0.4.js and find the lines ~234 - 237 there is a code there

// cross tab anchor link
  panes.find("a[href^=#]").click(function(e) {
  self.click($(this).attr("href"), e);		
  }); 

it's a code for cross-links, but the "find area" only inside the 'panes'. If you simply correct (replace) it to:


// find cross-tabs in whole document, not only in panes
  $("*",document.body).find("a[href^=#]").click(function(e) {
  self.click($(this).attr("href"), e);		
  }); 

it will take a cross-links in whole document, not only in the "panes".

I do this, it works (tested: IE 7,8, FF, Chrome, Opera). If nessesary, i can show an exaple (but it in Russian, if this not so problem :))

Luck!

kitz1980

Posts: 2

Registered:
Nov 9, 2009

adding another question to this.

Posted: Nov 9, 2009

Reply to: » How to open a tab with a link?, from PixeL
Opening a specified tab was working :)

How about opening the tab and making it jump to an anchor inside the content? is this possible?


<a href="#2ndTitle">jump</a>

<ul class="tabs">  
    <li><a href="#tab1">Tab 1</a></li>  
    <li><a href="#tab2">Tab 2</a></li>  
    <li><a href="#tab3">Tab 3</a></li>  
</ul>  
  
<!-- tab "panes" -->  
<div class="panes">  
    <div>First tab content. Tab contents are called "panes"</div>  
   
    <div>   
    <h2>Second tab content<h2>
    <p>blah... blah...</p>

    <a id="2ndTitle" name"2ndTitle"></a>
    <h2>second title</h2>
    <p>blah... blah...blah... blah...blah... blah...</p>
    </div>  

    <div>Third tab content</div>  
</div> 

pkrasko

Posts: 14

Registered:
Jul 29, 2009

This doesn"t seem to work for me...

Posted: Dec 22, 2009

Reply to: How to open a tab with a link?, from sijis
Assume a user bookmarks a url including the hash to activate the 2nd tab. When the page is loaded the first tab is always active. The initialIndex property isn't set in the tabs config.

Is there anything special you need to do?

In fact, I can't even get links within a tab pane to activate other tabs by using the href="#tabName".

In order for me to get the links working i had to manually bind my links to the click event and then use the tabs api handle to activate the proper tab.

I'm using the latest jQuery with tools 1.1.2 (tabs 1.0.4).

The only thought I have on this is maybe its broken because the tabs are using 'li' in the config rather than an anchor. I needed to use the 'li' because I need the 'active' class put on that element rather than the 'a' element. This is because I'm using image backgrounds on the tabs following the sliding doors technique.


<div class="contentTabWrapper">
    <ul class="contentTabs">
         <li class="active"><a href="#myNumbers">My Numbers</a></li>
         <li><a href="#addNumbers">Add a Local Number</a></li>                      
    </ul>
</div>

<div class="content">
<div class="tabPane" id="myNumbers">Tab content 1
     <a href="#addNumbers">Tab 2 anchor</a>
</div>
<div class="tabPane" id="addNumbers" style="display:none;">Tab Content 2 </div>
</div>


$("ul.contentTabs").tabs("div.content > div.tabPane", {
	current: 'active',
	tabs: 'li'
});

Ideas?

Bastien

Posts: 1

Registered:
Jan 13, 2010

I have the same problem

Posted: Jan 13, 2010

Reply to: This doesn"t seem to work for me..., from pkrasko
I have the same problem than pkrasko : the direct link to the tab (ie www.example.com/index.php#comments) isn't working : it doesn't select the correct tab (the first in fact) because I use tabs: 'li' option.

It would be great if someone could help us, if it's possible (maybe the current version 1.1.2 doesn't allow this feature)

greencode

Posts: 8

Registered:
Jan 16, 2010

Yep, me too

Posted: Jan 16, 2010

Reply to: I have the same problem, from octopus984
Yep, I'm having the same problem as well - when I create a link and then click on it - it adds the #link to the end of the url but fails to change the tab. Help!

greencode

Posts: 8

Registered:
Jan 16, 2010

Anyone?

Posted: Jan 28, 2010

Reply to: Yep, me too, from greencode
Does anyone have an answer to this? It's currently great that I can open a tab from within the tabs div but I really need to open up a link from outside the tab.

sijis

Posts: 4

Registered:
Nov 2, 2009

» Anyone?

Posted: Feb 24, 2010

Reply to: Anyone?, from greencode
You have to have the history plugin for the direct link to the tab to work.
http://flowplayer.org/tools/tabs.html#history

Once you have the plugin setup and working, then you can create link to the tab

<a href="http://domain.tld/page.html#tab1">Tab1</a>

This is how i got it working.

jqueryMan

Posts: 2

Registered:
Aug 21, 2010

» » Anyone?

Posted: Aug 23, 2010

Reply to: » Anyone?, from sijis
Thank you, thank you.

I just added history true like this:
$("ul.tabs").tabs("div.panes > div", { history: true });
And it works perfectly :)

nickli323

Posts: 1

Registered:
Sep 3, 2010

What I miss?

Posted: Sep 3, 2010

Reply to: » » Anyone?, from jqueryMan
Ok, trying to get this to work on my end so I can do some hard linking. Anybody see anything wrong with this?

http://ignacio-design.com/ecd/encino_cosmetic_dentistry_services.html

I'm not even getting the '#' anymore. Maybe I broke something... oye. I want to use this so I can hard link the footer links at the bottom. They all don't have to be put in a div pane correct?

- nick