在对话框中动态设置标题
问题描述:
var dlg = $("#dialog").dialog({
autoOpen: false,
modal: true,
buttons: {
'Update': function() {
alert(clientCode);
},
Cancel: function() {
$(this).dialog('close');
}
}
});
$(".edit").click(function() {
myval = $(this).parent().children('td:nth-child(1)').text();
dlg.dialog('open');
return false;
});
如何获取“myval”并将其作为对话框的标题?我试图在做dlg.dialog('open', myval)
时将它作为参数传递,但没有运气。我也试过将它作为参数传递,但也没有运气。然而,我可能以错误的方式做事。在对话框中动态设置标题
答
创建点击事件的对话框,并使用它来设置标题:
是这样的:
$(".edit").click(function() {
myval = $(this).parent().children('td:nth-child(1)').text();
var dlg = $("#dialog").dialog({
autoOpen: false,
title: myval,
modal: true,
buttons: {
'Update': function() {
alert(clientCode);
},
Cancel: function() {
$(this).dialog('close');
}
}
});
dlg.dialog('open');
return false;
});
答
$("#your-dialog-id").dialog({
open: function() {
$(this).dialog("option", "title", "My new title");
}
});