views:

506

answers:

3

I was able to display a dialog when clicking on a link. How do I the pull another page's contents while in the dialog?

A: 

Is the jQuery load() method what you are looking for?

Matt
I am not sure how to get a reference on the dialog window to make it load different content without closing and reopening.
PS: I just tried load, that did not work.
Try something like $('#theDialog').load('someOtherFile.html'); Then when you click the link, it will have the contents of the remote file. There are various ways of loading the file, but this is the most straight forward.
Jab
A: 

When you call a file via jquery's i.e. load-method, then it it is possible to load further content from the loaded file when it is dropped into the window dialog:

<script>
$(document).ready(function(){
  $("#myDropZone").load("another-file.html");
});
</script>

This code has to be returned from the loaded html content.

BTM, you can load content in different ways, but be aware of what you are doing. Do not load files recursively. Would be the same as a loop.

Hope this helps

Tom Schaefer
Should the above function reside in the html of the original page or dialog? I dont't understand which page responds to events inside the dialog, is it the dialog itself, or the page that invokes it?
Sorry, if I had not written clearly. I do mean the page, which is being invoked by your first request (not the dialog).
Tom Schaefer
+1  A: 

I've done this in the past by loading the 'other content' into a div and then displaying that div as a dialog.

$('#dialog').load('other_content.html', function(){ 
    $(this).dialog();
}

jQuery Docs for Ajax/load

Jon Dowdle
Thanks, but I would rather not pre-load other content, it will most likely delay the page load time.