I would do that something like this:

    $.get('markup.xml', function( xml ) {
        $(document).ready( function() {
            $('#name').autocomplete( $('#username',xml).get(), { ... });
            $('#department').autocomplete( $('#dept',xml).get(), { ... });
        });
    });

I don't know what you mean by "I'm reusing myXmlDoc" - if there's something
I missed, please clarify.

-Mike

> From: kempshall
> 
> How do I make sure that my script doesn't execute the $
> (document).ready() function until all of the external xml files that
> it's referencing are loaded? I have a framework that looks something
> like this:
> <script type="text/javascript" src="jquery.js"></script>
> <script type="text/javascript">
> var myXmlDoc;
> 
> $.get('markup.xml', function(data) { myXmlDoc = data; });
> 
> $(document).ready( function() {
>    $('#name').autocomplete($('#username', myXmlDoc).get(), { /*
> options */ });
>    $('#department').autocomplete($('#dept', myXmlDoc).get(), { /*
> options */ });
>    ...etc
> }
> </script>
> 
> Since I'm reusing myXmlDoc, I don't want to have to reload the file
> every time I reference it. But the way that it's written now, the
> variable gets referenced in $(document).ready before it's actually
> loaded. How do I deal with this situation?
> 
> Thanks
> 

Reply via email to