打开Jquery对话框的按钮不起作用 [英] Button to open Jquery Dialog is not working
问题描述
我正在使用Jquery UI
I am playing with Jquery UI
我通过DIV动态创建一个对话框,我给了这个DIV和ID以及一个调用closeDialog函数的按钮
I create a dialog on the fly from a DIV, i gave this DIV and ID and a button to call a closeDialog Function
如本例所示正常工作
我遇到的问题是,如果我加载包含该按钮的页面.该按钮不起作用
The problem I am having, is that if I d load a page THAT contains the BUTTON. The button will not work
如:
$("<div id='mydialog1'>").dialog({
autoOpen: false,
modal: false,
width: 740,
height: 840,
title: 'Dialog1 = dynamic',
open: function(e, ui){
$(this).load(myUrl);
}
});
推荐答案
如果这是按钮,请单击事件代码",然后
If this is the button Click Event code then
autoOpen: false,
应该是
autoOpen: true,
如果您不希望它一直打开到您单击按钮,则:
If you don't want it opened til you click the button then:
在要创建对话框时执行此操作.
Do this when you want the dialog created.
var $dialog = $("<div id='mydialog1'>").dialog({
autoOpen: false,
modal: false,
width: 740,
height: 840,
title: 'Dialog1 = dynamic',
open: function(e, ui){
$(this).load(myUrl);
}
});
并在他们单击按钮后执行此操作(仅在创建对话框之后)
and do this after they click the button (only after the dialog is created)
$("button_selector").click(function () {
$dialog.dialog("open");
});
尝试更改
function closeDialog1(){
alert('closing Dialog1');
window.parent.$('#mydialog1').dialog('close');
return false;
}
到
function closeDialog1(){
alert('closing Dialog1');
$('#mydialog1').dialog('close');
return false;
}
或者更好的方法可能是
$("<div id='mydialog1'>").dialog({
autoOpen: false,
modal: false,
width: 740,
height: 840,
title: 'Dialog1 = dynamic',
open: function(e, ui){
$(this).load('dialogtest1a.html');
},
buttons: {
"Close" : function () {
$(this).dialog("close");
}
}
});
关闭对话框的按钮是否必须在您正在加载的页面中?
Does the button that closes the dialog HAVE TO be in the page you are loading?
这篇关于打开Jquery对话框的按钮不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!