chuck w
chuck w

Reputation: 1761

Stop first jquery ui tab from preloading content with ajax

I currently user jquery ui to create a dialog window that is hidden on page load. The user opens the dialog by clicking a button. Once open, the dialog has several tabs (created with jquery ui tabs), each one displaying a form that a user might need access to. The actual forms are loaded using ajaxOptions.

Is there a way to stop jquery from preloading my first ui tab on page load? Instead, I want the content of the first tab loaded only when the user clicks the button to open the dialog.

    $( "#pref_tabs" ).tabs({
    ajaxOptions: {
        success: function(xhr, status, index, anchor) {
           //function to handle successful loading
        },
        error: function( xhr, status, index, anchor ) {
            $( anchor.hash ).html(
                "Couldn't load this form. We'll try to fix this as soon as possible. ");
        },
    }
});

Upvotes: 1

Views: 1529

Answers (1)

Kevin B
Kevin B

Reputation: 95030

Add an additional option to your tabs options to make no tabs selected by default.

$(sel).tabs({
    selected: -1,
    ajaxOptions: {...
});

Upvotes: 4

Related Questions