简体   繁体   中英

jQuery UI accordion open after loading jQuery Ajax

I'm using jQuery UI accordion for the first time and I have a question: How I can delay the opening after all Ajax data is loaded?

Here is the accordion code:

var ac = $("#accordion").accordion(
    { 
        active: false, 
        event: false, 
        autoHeight: false, 
        navigation: false 
    }, 
    { header: "table" }
);

I know I can start open animation in this function:

$(".SearchResults").load(
    url, 
    { input: id }, 
    function () { 
        hideProgress(); 
    }
);

After hideProgress it will run. How I can start opening?

Try moving the accordion initialisation to the callback, after hideProgress() , like this:

$(".SearchResults").load(
    url, 
    { input: id }, 
    function () { 
        hideProgress(); 
        var ac = $("#accordion").accordion(
            { 
                active: false, 
                event: false, 
                autoHeight: false, 
                navigation: false 
            }, 
            { header: "table" }
        );
    }
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM