打开后清除了 JQuery 对话框内容
JQuery Dialog box content cleared after open
我有这段代码,可以打开一个对话框,其中包含从 php 类生成的内容,但问题是在 2 秒内代码从对话框中清除。以下是JavaScript/JQuery:
$k('#CreateTable').click(function(e){
e.preventDefault();
var Call = $k('#CreateTable').attr('value');
var util = $k(this).attr('id');//.attr('value');
// alert(util);
$k('#dialog').dialog({
autoOpen: false,
title: 'Running Utility for: '+Call,
modal: true,
width: 450,
close: function(event, ui) {
$k("#dialog").empty(); // remove the content
}//END CLOSE
}).dialog('open');
$k.ajax({
type: "post",
url: "inc/runUtilities.php",
dataType: "html",
data: {
'utility' : util
},
success: function(data) {
//alert('success');
$k('#DlgTxt').html(data).fadeIn('slow');
}
});
//return false;
});//END DIALOG
它从以下按钮代码触发:
<div class="tab-pane fade in active" id="Utilities">
<p>
<div>
<button class="btn btn-lg btn-default" type="button"
value="Create Table" id="CreateTable" >Create Table</button>
</p>
</div>
</div>
我缺少什么吗?
只需删除".k"即可:$.k() 到 $()
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
$('#CreateTable').click(function(e){
e.preventDefault();
var Call = $('#CreateTable').attr('value');
var util = $(this).attr('id');//.attr('value');
// alert(util);
$('#dialog').dialog({
autoOpen: false,
title: 'Running Utility for: '+Call,
modal: true,
width: 450,
close: function(event, ui) {
$("#dialog").empty(); // remove the content
}//END CLOSE
}).dialog('open');
$.ajax({
type: "post",
url: "YOUR URL HERE",
dataType: "html",
data: {
'utility' : util
},
success: function(data) {
//alert('success');
$('#DlgTxt').html(data).fadeIn('slow');
}
});
//return false;
});//END DIALOG
});
</script>
</head>
<body>
<div class="tab-pane fade in active" id="Utilities">
<p>
<div>
<button class="btn btn-lg btn-default" type="button"
value="Create Table" id="CreateTable" >Create Table</button>
</p>
</div>
</div>
</body>
</html>
相关文章:
- 使用jquery对话框中的箭头键
- 获取打开jquery对话框的button的id
- 我怎么能让jQuery对话框表现得像Javascript警报
- 如何在页面重新加载时显示jquery ui对话框
- 如何为javascript方法放入jquery确认对话框
- Jquery UI对话框不会消失
- jQuery UI对话框错误,按钮导致HierarchyRequestError
- 如何在jquery中检测浏览器的后退按钮,如果有任何对话框打开,请关闭它
- 获取活动的jQuery UI对话框
- 使用模态对话框(JQuery)编辑函数
- 无法在其他调用上设置jQuery对话框选项
- jQuery UI模式对话框覆盖淡出
- 如何在jQuery对话框标题栏中添加额外的按钮
- 从jquery对话框恢复原始数据,脚本不起作用
- jQuery模态弹出的行为类似于确认和警报对话框
- 单击按钮创建多实例jQuery UI对话框
- JQuery UI对话框在重新打开时未正确调整大小
- Jquery对话框('打开')不工作
- 保存对话框jquery
- 打开覆盖(模态对话框)jquery工具在页面加载