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:
- 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.
- $('.modal').click(function(e) {
- e.preventDefault();
- $.get(e.target.href, function(data) {
- var uid = Math.floor(Math.random() * 165);
- $(data).wrapAll("<div id='dialog-" + uid + "' />").parent().appendTo('body');
- $("#dialog-" + uid).dialog({title: e.target.title});
- });
- });
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):
- uiDialogTitle = $('<span></span>')
- .addClass('ui-dialog-title')
- .attr('id', titleId)
- .html(title)
- .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.