Unfortunately the callback on click() never occurs: $("#say_hello").click(function() { $("body").prepend('<link type="text/css" rel="stylesheet" href="css/ jquery-ui.min.css" />') $.getScript("js/mail.js"); }, function() { alert("done"); });
As a hack, I can attach the event to the getScript() callback, since it takes roughly the same time to load as the stylesheet: $("#say_hello").click(function() { $("body").prepend('<link type="text/css" rel="stylesheet" href="css/<? php echo Page::JQUERY_UI_CSS; ?>" />') $.getScript("js/mail.js", function() { $("#say_hello_box").dialog("open"); }); }); This still doesn't address the original problem, though. Any other ideas? (I really do appreciate the help, Alex) On Aug 10, 10:04 am, Alexander Freiria <xanderco...@gmail.com> wrote: > You could dialog box in the callback of the click funciton... > > $("#say_hello").click( > > > > > > > function() { > > $("body").prepend('<link type="text/css" rel="stylesheet" > > id="example" href="css/jquery-ui.min.css" />'); > > $.getScript("js/mail.js"); > > $("#say_hello_box").dialog("open"); > > }); > > On Mon, Aug 10, 2009 at 12:51 PM, ebakunin <ebaku...@gmail.com> wrote: > > > Hello, > > > When a user clicks a button I dynamically load large CSS and JS files. > > I handle it in this way: > > > $("#say_hello").click(function() { > > $("body").prepend('<link type="text/css" rel="stylesheet" > > id="example" href="css/jquery-ui.min.css" />'); > > $.getScript("js/mail.js"); > > $("#say_hello_box").dialog("open"); > > }); > > > It works great, but the problem is that sometimes the dialog box opens > > before the CSS has loaded. I would like to add the equivalent of $ > > ("#example").load(), since using load() does not seem to work. Can > > anyone recommend a way to do this? Thanks for the help. > > -- > Regards! > > Alexander Freiria - Programmer\Web Developerhttp://www.xandercs.com/ > xanderco...@gmail.com > 954.549.3666