InvalidSyntax
InvalidSyntax

Reputation: 9495

jQuery UI Tabs loading specific link within tab

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

Upvotes: 2

Views: 1454

Answers (1)

brianpeiris
brianpeiris

Reputation: 10795

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.

Upvotes: 2

Related Questions