views:

286

answers:

1

I want to load only links within a certain div inside the tab, otherwise it should just go to the actual link.

Current the code i use loads all links inside the content in the same tab

<script type="text/javascript">
      $(function(){
        $('#tabs').tabs({
          load: function(event, ui) {
            $('a', ui.panel).click(function() {
              var tabId=$('#tabs').tabs('option', 'selected');
             $('#tabs').tabs("url", tabId, this.href).tabs("load",tabId);
              return false;
            });
          }
        });
      }); 
</script>

Tab Page

    <div id="sresults" style="width: 520px">
 <div id="tabs">
  <ul>
   <li><a href="mylink.html">Songs</a></li>
   <li><a href="mylink.html">Albums</a></li>
   <li><a href="mylink.html">Videos</a></li>
   <li><a href="mylink.html">Entire Blog</a></li>
  </ul>
 </div>
</div>

And then heres the page inside the tab

<div id="content">
<a href="permalink.html">My links</a>
</div>

<div id="navi"><a href="tab?page=2">Next Page</a>
</div>

I want the links inside the navi div to load within the tab, but all links outside should go to the actual link

A: 

I'm guessing you only want to load the navigation links inside the tab.

If so, just replace

$('a', ui.panel).click(function() {

With

$('#navi a', ui.panel).click(function() {

Although, I suggest you use a class to select your navigation div instead of using an id because you might end up with duplicate ids, which could cause problems later on.

brianpeiris
thanks for the solution, plus the suggestion ;-)
Imran
Would it be possible to now have the page scroll back to the top of the tab?
Imran
`$('html').scrollTop(0);` before `return false;` should do it. I'm not sure if that will work for anything other than Firefox and IE8 though.
brianpeiris
Worked like a charm
Imran