我想構建一個通用函數,我可以從應用程序的任何地方通過傳遞自定義參數傳遞到jQuery UI確認對話框。我一直在尋找和嘗試不同的東西,但以下是我想要使用的邏輯。我究竟做錯了什麼?任何幫助深表感謝。Jquery UI對話框動態函數與傳遞參數
下面是函數:
function popDialog(h, w, deny_btn, confirm_btn, confirm_title, confirm_message, deny_action, confirm_action) {
var newDialog = $('<div id="dialog-confirm">\
<p>\
<span class="ui-icon ui-icon-alert" style="float: left;margin: 0 7px 60px 0;"></span>\
' + confirm_message + '\
</p>\
</div>');
newDialog.dialog({
resizable: false,
height: h,
width: w,
modal: true,
autoOpen:false,
title: confirm_title,
buttons: [
{text: deny_btn: click: function() {deny_action}},
{text: confirm_btn: click: function() {confirm_action}}
]
});
}
這裏是呼叫:
$("#cancel").click(function(e) {
popDialog("210", // height
"350", // width
"No", // deny_btn
"Yes", // confirm_btn
"Confirm Cancel", // confirm_title
"Are you sure you would like to cancel? Changes will not be saved.", // confirm_message
$('#dialog-confirm').dialog('close'), // deny_action
window.location = '/some/location/index/<?= $class->getClassid() ?>'); //confirm_action
});
這將有助於瞭解目前您有什麼問題......你得到錯誤? –
可能的問題是由於高度和寬度是無效的字符串。要麼使用整數(不包括引號),要麼使用「210px」和「350px」。 –
謝謝我摘下報價。仍然有同樣的問題,但看不到我得到什麼錯誤。我在受保護的網址上使用了Chrome和Firebug Lite,因此沒有得到很好的錯誤。只有通用的'未捕獲的SyntaxError:意外的令牌<「 –