2

I'd like to be able to target where the AJAX content ends up. Does anyone have any ideas?

<div class="tabs">
  <ul>
    <li><a href="ajax/content1.html">tab1</a></li>
    <li><a href="ajax/content1.html">tab1</a></li>
  </ul>
</div>

<div id="tab-content-target">
... this is where new tabs get created
</div>

2 Answers 2

1

This should do the trick.

$('a').click(function(e){
    e.preventDefault();
    $('#tab-content-target').load($(this).attr('href'));
});
Sign up to request clarification or add additional context in comments.

2 Comments

This would work, except the jquery-ui-tabs function ultimately replaces the href on the links with the tab's ID, and no doubt creates the events to make the ajax call. So I lose the ability to load the href. Otherwise this would have worked.
can you make the actual href value in a different attribute that wont be removd? like alt or title or rel?
1
<div class="tabs">
  <ul>
    <li><a href="ajax/content1.html" class='aLink'>tab1</a></li>
    <li><a href="ajax/content1.html" class='aLink'>tab2</a></li>
  </ul>
</div>

<div id="tab-content-target">
    ... this is where new tabs get created
</div>

<script type='text/javascript'>
    $('.aLink').click(function(){
           $.ajax({ $(this).attr('href'),success: function(data){
                       $('#tab-content-target').html(data);                        
                     }
           });
           return false;
    });
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.