1

It's probably a simple quesiton but I can't figure out how I could realize it. I have the following code:

<div id="tabContainer" dojoType="dijit.layout.TabContainer" region="center" tabStrip="true">
<div id="tab1" dojoType="dijit.layout.ContentPane" title="TITLE1" selected="true">   
LINK TO TAB2    
</div>
<div id="tab2" dojoType="dijit.layout.ContentPane" title="TITLE2" selected="false">     
some text
</div> 

What I want to do is have a link from Tab1 to Tab2. If I use the following link it doesn't work:

<a href="name_of_the_file.html#TITLE2">

If I put the same link on another html file it works perfectly. Any advice how the correct link should look like? Thank s alot!

TTP

TTP
  • 31
  • 2
  • Follow up question on http://stackoverflow.com/questions/6375485/linking-to-a-specific-tab-contentpane-with-dojo , that's why the external link works. If in the same page, you need to check for hash changes. Care to accept the previous answer? – Gustavo Giráldez Jun 21 '11 at 02:40
  • Hmmm... But it doesn't work within the same page, that's why I asked. Can you provide a solution for this? – TTP Jun 29 '11 at 15:35

1 Answers1

1

If HTML is like this:

<div id="tabContainer" dojoType="dijit.layout.TabContainer">
 <div id="tab1" dojoType="dijit.layout.ContentPane" title="TITLE1">   
  <a href="#" id='linktosecond'>LINK TO TAB2</a>
 </div>
 <div id="tab2" dojoType="dijit.layout.ContentPane" title="TITLE2">     
  some text
 </div>
</div>

we can add an onclick event to the hyperlink node to move to desired tab

<script>
  dojo.ready(function() {
    dojo.byId('linktosecond').onclick = function() {
      dijit.byId('tabContainer').selectChild(dijit.byId('tab2'));
    }
  });

</script>
vivek_nk
  • 1,590
  • 16
  • 27