您的标记是否将href值设置为editform可用的页面。您使用querystring将记录的id传递到此页面,以便您可以将该记录的详细信息加载到编辑表单。
<a href="edtiuser.php?userid=1">Edit User 1</a>
<a href="edtiuser.php?userid=2">Edit User 2</a>
并且有这个脚本。
$(function(){
$("a.editlink").click(function (e) {
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:hidden"></div>').appendTo('body');
}
dialog.load(
url,
{}, // omit this param object to issue a GET request instead a POST request, otherwise you may provide post parameters within the object
function (responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
close: function (event, ui) {
dialog.remove();
},
modal: true,
width: 460
});
}
);
return false;
});
});
所以,当你点击锚标签时,你的edituser.php页面的内容将被加载到对话框中。这应该很好,假设你有jQuery和jQuery UI正确加载到你的页面。
我喜欢这种方法,但是有一件事我难以理解,我会如何将链接中的id传递给打开的函数,以便将它传递给我的ajax调用?因此,让我们说在父页面上,我有一个像这样的链接Edit当他们点击我打开对话框时,如何从我刚刚从打开的函数中点击的链接访问标题属性? – John 2012-04-17 01:58:21
好的,将你的初始函数改为: $(“a.editlink”)。click(function(this)在这个DO AJAX调用中.title $(“#edit-form”)。dialog(“open “); ... – 2012-04-17 16:52:57