Link to home
Start Free TrialLog in
Avatar of brianmfalls
brianmfallsFlag for United States of America

asked on

How do I run a function after all of my html files have completed loading via jQuery .load()?

Using a setTimeout function is just to hacky...  I need to run some scripts after all of the documents are loaded.  Load time varies from server to server, so setTimeout is not only hacky, it's unreliable at best.  How do I run a function after all of my html files have completed loading via jQuery .load()?

        for (i = 1; i < 53; i++) {
            if (i.toString().length == 1) {
                index = '0' + i.toString();
            } else {
                index = i;
            };
            $('#manualBody').append('<div id="chapter'+index+'Container"></div>');
            $('#chapter'+index+'Container').load('docs/chapter'+index+'.html');
        };
        setTimeout(function(){
            for (i = 1; i < 7; i++) {
                $('#manualBody').find('h'+i).attr('id','fullManual');
            };
        }, 2800);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of brianmfalls
brianmfalls
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brianmfalls

ASKER

Problem solved...