在JQuery对话框中加载动态内容 [英] Loading dynamic content in JQuery dialog
本文介绍了在JQuery对话框中加载动态内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将动态内容加载到新的JQuery对话框中有问题。当我点击按钮没有任何反应。
I have a problem loading dynamic content into a new JQuery dialog. When I click on the button nothing happens.
我的代码如下:
<script src="jquery-ui.min.js"></script>
<script>
//$('#dialog').dialog({ dialogClass: 'noTitleStuff' }); ---> CSS
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
height:$(window).height() - 50,
width:$(window).width() - 50,
show: {
effect: "blind",
duration: 400,
},
hide: {
effect: "explode",
duration: 400
}
});
$( "#opener" ).click(function() {
$( "#dialog").dialog({
open: function(event, ui) {
$('#content').load('http://www.google.com');
}
});
});
});
</script>
</head>
<body>
<div id="dialog">
<div class="content"></div>
</div>
<button id="opener">Open Dialog</button>
</body>
推荐答案
您必须在初始对话框()设置中定义打开的功能:
you have to define the open function in the initial dialog() setup:
$("#dialog").dialog({
autoOpen: false,
height: $(window).height() - 50,
width: $(window).width() - 50,
show: {
effect: "blind",
duration: 400,
},
hide: {
effect: "explode",
duration: 400
},
open: function (event, ui) {
$('#content').load('http://www.google.com');
}
});
并像下面这样调用:
$("#opener").click(function () {
$("#dialog").dialog('open');
});
ps:你正在使用 $('#content')
html你定义 class =content
p.s.: you're using $('#content')
but in the html you define class="content"
这篇关于在JQuery对话框中加载动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文