Javascript 关闭jQuery对话框
出于某种原因,我有这个代码显示像一个弹出窗口Javascript 关闭jQuery对话框,javascript,php,jquery,html,yii,Javascript,Php,Jquery,Html,Yii,出于某种原因,我有这个代码显示像一个弹出窗口 <div id="myDialog" title="myTitle"> <div class="table_cell"> <div class="message"></div> </div> <div class="table_cell" onclick="doMyThing(<?php echo $id; ?>)"> <span s
<div id="myDialog" title="myTitle">
<div class="table_cell">
<div class="message"></div>
</div>
<div class="table_cell" onclick="doMyThing(<?php echo $id; ?>)">
<span style="cursor:pointer">Accept</span>
</div>
</div>
这很好用。尽管如此,我需要在单击“跨度”字段后隐藏/关闭对话框。我尝试过类似于$('#myDialog').dialog('close')代码>但它不工作。另外,尝试在“myDialog”display:block
中首次单击,然后单击display:none
,但对话框仍保持在屏幕上
这个“myDialog”实际上从css中获得了一些样式,这就是为什么我要编写这样一个假对话框。有什么建议吗?.dialog('close')
应该可以。正确参考跨度
<div id="myDialog" title="myTitle">
<div class="table_cell">
<div class="message"></div>
</div>
<div class="table_cell" onclick="doMyThing(<?php echo $id; ?>)">
<span id='accept' style="cursor:pointer">Accept</span>
</div>
</div>
$(document).ready(function() {
$('#myDialog').dialog();
$('.message').html("Some text");
$('#accept').on('click', function(){
$('#myDialog').dialog('close');
})
});
您可以使用提供的按钮,而不是自己制作
jQuery:
$(document).ready(function() {
$( "#mydialog" ).dialog({
modal: true,
buttons: {
"Accept": function() {
doMyThing(<?= $id ?>);
$( this ).dialog( "close" );
}
}
})
});
$(文档).ready(函数(){
$(“#mydialog”).dialog({
莫代尔:是的,
按钮:{
“接受”:函数(){
doMyThing();
$(此).dialog(“关闭”);
}
}
})
});
HTML:
您可以在此处查看正确的文档:检查
这些项目将被永久删除,无法恢复。你确定吗
$(函数(){
$(“#对话框确认”)。对话框({
可调整大小:false,
身高:140,
莫代尔:是的,
按钮:{
“删除所有项目”:函数(){
$(此).dialog(“关闭”);
},
取消:函数(){
$(此).dialog(“关闭”);
}
}
});
});
我终于使用了jQuery按钮并改变了它的外观。我试图在那里使用css类,但没有成功
$(document).ready(function() {
$('.message').html("Some text");
$( '#myDialog' ).dialog({
modal: true,
buttons: {
'accept': {
style:'background:#D1040E; color: #DADADA',
text: 'Accept',
click: function() {
doMyThing(<?php echo $id; ?>);
$( this ).dialog( 'close' );
}
},
'cancel': {
style:'background:#D1040E; color: #DADADA',
text: 'Cancel',
click: function() {
$( this ).dialog( 'close' );
}
}
}
});
});
$(文档).ready(函数(){
$('.message').html(“一些文本”);
$('#myDialog')。对话框({
莫代尔:是的,
按钮:{
“接受”:{
风格:'背景:#D1040E;颜色:#达达',
文本:“接受”,
单击:函数(){
doMyThing();
$(this.dialog('close');
}
},
“取消”:{
风格:'背景:#D1040E;颜色:#达达',
文本:“取消”,
单击:函数(){
$(this.dialog('close');
}
}
}
});
});
您是如何绑定单击触发关闭事件的?请尝试将显示:无
应用于其父项
<div id="myDialog" title="myTitle">
<div class="table_cell">
<div class="message"></div>
</div>
</div>
<div id="dialog-confirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>
<script>
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Delete all items": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
</script>
$(document).ready(function() {
$('.message').html("Some text");
$( '#myDialog' ).dialog({
modal: true,
buttons: {
'accept': {
style:'background:#D1040E; color: #DADADA',
text: 'Accept',
click: function() {
doMyThing(<?php echo $id; ?>);
$( this ).dialog( 'close' );
}
},
'cancel': {
style:'background:#D1040E; color: #DADADA',
text: 'Cancel',
click: function() {
$( this ).dialog( 'close' );
}
}
}
});
});