AJAX Generated Dialog

AJAX Generated Dialog

I'm attempting to use jQuery.get to load content from an external page into a jQuery UI Dialog and present it to the user. I've gotten this far, but keep running into an error:
  1. Uncaught TypeError: Cannot call method 'prependTo' of undefined jquery-ui-1.8.2.js:824
I've been trying to debug this for a while now and can't seem to get anywhere. I had it working for a couple minutes while messing around in the console, then it broke again when I put what was working on the page.
  1. $('.modal').click(function(e) {
  2.       e.preventDefault();
  3.       $.get(e.target.href, function(data) {
  4.             var uid = Math.floor(Math.random() * 165);
  5.             $(data).wrapAll("<div id='dialog-" + uid + "' />").parent().appendTo('body');
  6.             $("#dialog-" + uid).dialog({title: e.target.title});
  7.       });
  8. });
That runs once the DOM is ready and applied to all anchor tags with the modal class. The uid stuff was added as part of a possible solution and probably isn't necessary, this is simply where I'm at now and can't get around this error.

To verify this is what I have in my jquery-ui-1.8.2.js file for line 824 (The final line being 824):
  1. uiDialogTitle = $('<span></span>')
  2.       .addClass('ui-dialog-title')
  3.       .attr('id', titleId)
  4.       .html(title)
  5.       .prependTo(uiDialogTitlebar);
I've tried setting (and not setting) a title in the .dialog call, but nothing ever changed, I still got the same error.

Any guidance with this is greatly appreciated.