views:

106

answers:

1

I'm a bit of a n00b with jquery so this one is probably an RTFM question:

I'm writing an application to create a somewhat complex record for my client. Building the record requires doing a couple of server side searches inside a dialog.

Right now I have everything framed up in 1 file (asp.net) and it's ok. But I can see as I add the business logic and the communication with the server this is going to get really ugly. I'm alreay putting most of the javascript in external files, but I'd like to move the HTML for the dialogs out too.

How do I get the jquery dialog method to load the dialog body from the html files? Something like:

getDialogHTML(dialogHolderDiv); <---magic goes here var dialogOptions = { ... }; $("#"+dialogHolderDiv).dialog(dialogOptions); $("#"+dialogHolderDiv).dialog('open');

any help will be apperciated .

+2  A: 

You can use the jQuery load() method to load an external file into an element.

e.g.:

var myDiv = $('#dialogDiv');
myDiv.load('/MyDivContent.html');

There are additional options if you want to display only a portion of the content, pass parameters, etc.

technophile
sweet! I give it a try. Really apperciate the answer.
Jake