Rectangle 27 0

Try adding this script in the ready event and after the tabs are created:

$('#tabs-' + (jLikeToSet + 1) + ' a').click();

it's not only in tabs-2, but in the tab with the index store in jLikeToSet, in this case 1 but can be 0 or 2

@Kris: Solution posted by Manji is the better one. One small change you would need to do is to use it this way: $("#tabs").tabs( "select" , jLikeToSet);

ajax - jQuery simulate click on tab with code execution - Stack Overfl...

jquery ajax
Rectangle 27 0

I myself would change the jQuery to the following:

$(document).ready(function() {
    var $tabs = $("#tabs").tabs();
    $('#tabs li a').click(function(){
        $.post('/Home/e'+location.hash.replace('#tabs-',''), function (data) {
            $(location.hash).html(data);
        });
    });
});

ajax - jQuery simulate click on tab with code execution - Stack Overfl...

jquery ajax
Rectangle 27 0

To select programmatically a tab, call this function with jLikeToSet arg:

function selectTab(jLikeToSet){
    $("#tabs").tabs( "select" , jLikeToSet);
}

when this function is executed, it's as if you have selected manually, so what's inside .bind('tabsselect' will be executed.

This is much cleaner than the one I have posted. I was not aware of the select option. +1

with this code, I select the tab (index in jLikeToset) but nothing happen when I click on the tabs. I'd like, in some case, set a tab and execute the coede ... your solution is ok but I need to be able to execute code when I click on tab too.

FYI, I used "e1","e2" ... but can be "aaaa", "bbbb", "azerty"

As of jQuery UI 1.8 the "select" option has been deprecated, and removed in 1.9. Use the "active" instead as below: $("#tabs").tabs("option", "active", tabIndex);

ajax - jQuery simulate click on tab with code execution - Stack Overfl...

jquery ajax