views:

233

answers:

1

I am trying to get a modal loading dialog to pop up while I make an ajax call but it is not showing up in the onClick function. If I slow it down with firebug and step through the loading panel will show up. Is this just javascript running ahead of itself? Is there a better way to do this?

$(function(){
     $("#loading_panel").dialog({
                                 modal:true,
                                 position:'center',
                                 minHeight:40
                                });

     $("a.view-in-frame").click(function(){
                       $("#loading_panel").dialog('open');
                       $("#tabs").hide();
                       var blog = $(document.createElement('div')).attr('id', 'blog').load(('blog_reader.php?blog='+this.href)), $("#loading_panel").dialog('close'));
                       $("#content_wrap").append(blog);
                       return false;
                 });
})
+1  A: 

Just an idea, try setting the 'autoOpen' to false when creating the dialog:

$("#loading_panel").dialog({
                             modal:true,
                             position:'center',
                             minHeight:40,
                             autoOpen:false
                            });

At the moment you are telling the dialog to open when it is created. This should prevent that behaviour.

Nat Ryall
no that didn't fix it
ErsatzRyan
Either way, it should be in there. :)
Nat Ryall