views:

135

answers:

1

Hello,

I would like to be able to click on an achor element from a page inside a jQuery tab and have that new page load directly inside the original tab. I used sample code from the jQuery tutorial page but to no avail!

When I click on the anchor tag, I get redirected to www.google.com but lose my tabs. Does anyone know what I'm doing wrong? would really appreciate it. Thanks!

$(document).ready(function(){
    $("#tabs").tabs();
});
$('#tabs').tabs({
    load: function(e, ui) {
        $('a', ui.panel).click(function() {
            $(ui.panel).load(this.href);
            return false;
        });
    }
});
A: 

I'm guessing that #tabs is not present when that second statement is executed, and so the load event is never added.

Try this

$(document).ready(function(){
    $('#tabs').tabs({
        load: function(e, ui) {
            $('a', ui.panel).click(function() {
                $(ui.panel).load(this.href);
                return false;
            });
        }
    });
});
Sean Kinsey
I tried that code but when I click on the anchor, the tab goes blank and all content disappears (nothing starts loading either). Any ideas?
tabs_newbie
I don't do jQuery, but I guarantee you that this is more correct than your code due to how a page loads :) But your code is according to the documentation... But hey, thats what you get for using jQuery ;)
Sean Kinsey
Btw, are you only planning on asking tabs related questions?
Sean Kinsey