我有表格和表格。表中的一列是用于编辑行的按钮。我必须在单击按钮时打开模式对话框,对话框将包含另一个表,其结果集基于我单击按钮的行。当我单击表格的每一行上的按钮时,我需要页面提交并打开模态对话框。目前,当页面提交发生时,模态正在关闭。下面是我的剧本
$('body').on('click', '.button', function() {// button is the first column
// in each row
pid = $(this).closest('tr').find('td:eq(2)').text();
document.getElementById('text').value =pid; // Modal dialog table result set
// depends on this pid
$("#getuser").submit(); // form (if we dont submit dialog is not show the
// result set for current pid selected. instead
// showing the old pid
$( "#exe-scroll" ).dialog({ // dialog
maxWidth:600,
maxHeight: 500,
width: 700,
height: 500,
resizable:true,
modal: true,
close: function() {
});
});
如何提交页面并打开一个模式对话框,该对话框将显示所选当前pid的记录集。 提前致谢
答案 0 :(得分:0)
好的,我会尽量解释一下!
<div id="container" style="max-width: 618px; height: 275px;"></div>
现在,如果你想将数据设置到模态中的表格,那么你可以在模态打开之前或之后成功完成!这里的基本要点是你需要从服务器端函数返回适当的细节对象并通过$('body').on('click', '.button', function() {
pid = $(this).closest('tr').find('td:eq(2)').text();
$.ajax({
url:'/ServerSideFunction/', //Call a serverside function which accepts pid as parameter and retrieves the details from database and return data of type json from the same,
type:'POST',
dataType:'json',//return type from server side function [return it as JSON object]
contentType: "application/json",
data: JSON.stringify(pid), //Pass the data to the function on server side
success: function (data) { //Result object _[say user object]_ returned from server side function and then call modal on success
$( "#exe-scroll" ).dialog({ // dialog
maxWidth:600,
maxHeight: 500,
width: 700,
height: 500,
resizable:true,
modal: true,
close: function() {
});
});
},
error:
function (data) {
//display any unhandled error
}
});
});