Aut*_*cus 0 javascript jquery jquery-ui modal-dialog jquery-dialog
我希望能够在运行时更改模态和按钮的标题.目前我有这个我有批准或拒绝的行动
var recButton = actions =='approval' ? 'Approve' : 'Deny';
$("#dialog").dialog(
{
modal : true,
buttons : {
'update all' : function() {
// window.location.reload();
// $( this ).dialog( "close" );
//do something here
},
Cancel : function() {
$(this).dialog("close");
}
}
}); //dialog
});
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个按钮
$("#dialog").dialog(
{
modal : true,
buttons : {
recButton : function() { ...
Run Code Online (Sandbox Code Playgroud)
但在模态中它没有很好地转换,只是说recButton而不是变量值.我也需要更改标题.
更新:通过简单标题获得标题:
嘿Autolycus:试试这个男人:工作演示 http://jsfiddle.net/C4A9b/10/
请使用firebug检查元素id/class:
$('.ui-dialog-title').html("HULK is awesome"); 应该做的伎俩.
希望能帮助到你 :)
码
$(document).ready(function() {
$('#theLink').click(function(){
$( "#forgot-dialog" ).dialog( "open" );
});
$( "#forgot-dialog" ).dialog({
modal: true,
autoOpen: false,
height: 255,
width: 300,
buttons: {
"ChangeTitle": function() {
alert("Title before cahnge ==> " + $('.ui-dialog-title').html());
$('.ui-dialog-title').html("HULK is awesome");
// document.forms["forgotform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
});
Run Code Online (Sandbox Code Playgroud)
要么
var formname = "form_name_here";
$("#ui-dialog-title-"+formname).innerHTML = "Hulk is awesome title";
Run Code Online (Sandbox Code Playgroud)
下面的图像显示之前和之后.
单击changetitle按钮之前的图像

点击更改标题后
