这就是我打开对话框的方法,我很久以前就找到了一个教程,但我忘记了那个教程的链接
$("#dialog1").html("Mr. " + "<span id='name'>" + data[i].name + "</span>" + "has a building property in <span id='address'>" + data[i].address + "</span>");
$("#dialog1").dialog({title: pml});
$("#dialog1").dialog("open");
这就是我创建对话框的方式
var div = $("<div id='dialog1'>");
$("body").prepend(div);
$("#dialog1").dialog({
autoOpen: false,
resizable: false,
modal: true,
//title: "Modal",
height: 250,
width: 400,
buttons: {
"Add": function() {
$(this).dialog('close');
},
"No": function () {
$(this).dialog('close');
},
"close": function () {
$(this).dialog('close');
}
}
});
目前按钮add and no
具有关闭对话框的功能,但我希望以add button(which is inside the dialog box) is clicked
我将获得html of the dialog
中的跨度值的方式添加函数以便我可以将其用作parameter for ajax request
答案 0 :(得分:2)
您可以简单地执行&#34;添加&#34;功能:
...
"Add": function() {
$(this).dialog('close');
somefunction($('#span_id').text()); // #span_id = id of span whitch you want to get text from
},
...
和
function somefunction(text) {
// ajax call
}