i have a page where i will create a iframe dynamically and append that to a div. That div will be attached to a jquery dialog.
<div id="diviframe"></div>
<script>
var iFrame = $('<iframe id="thepage" width="450" height="400"></iframe>').appendTo("#diviframe");
var iFrameDoc = iFrame[0].contentDocument || iFrame[0].contentWindow.document;
iFrameDoc.write('<p>Some useful html</p>');
iFrameDoc.write('<p>Some useful stuff</p>');
iFrameDoc.close();
$("#diviframe").dialog({
autoOpen: false,
modal: true,
height: 500,
width:500,
open: function(ev, ui) {
}
});
$("#diviframe").dialog('open');
The contents of iframe is not written when its opened in jquery dialog. can anyone suggest a workaround for this?
Update:
function test() {
var iFrame = $('<iframe id="thepage" width="500" height="500" src="http://stackoverflow.com"></iframe>').appendTo("#diviframe");
var parent = "divparent";
var iFrameDoc = iFrame[0].contentDocument || iFrame[0].contentWindow.document;
iFrameDoc.write('<p>Some useful html</p>');
iFrameDoc.write('<p>Some useful stuff</p>');
iFrameDoc.close();
return iFrame;
}
var $dialog; //Must be at the global scope
function dialog() {
alert(1);
$.get(test, {}, function(html) {
$dialog.html(html);
$dialog.dialog("open");
});
}
$(function() {
//Initialize (without showing it)
var $dialog = $('<div id="dialog" title=""></div>').dialog({
autoOpen: false,
modal: true
});
});
dialog();
I tried to call a function dynamically after the jquery dialog loads but its showing some errors. How to load a function from jquery dialog?