3 回答

TA貢獻1966條經驗 獲得超4個贊
您應該能夠解決它。更正是在單擊事件的按鈕的對話框選項的設置器中。
$(document).ready(function() {
? ? $("#dialog").dialog({
? ? ? ? modal: true,
? ? ? ? bgiframe: true,
? ? ? ? width: 500,
? ? ? ? height: 200,
? ? ? ? autoOpen: false
? ? });
? ? $(".lb").click(function(e) {
? ? ? ? e.preventDefault();
? ? ? ? var theHREF = $(this).attr("href");
? ? ? ? $("#dialog").dialog('option', 'buttons', {
? ? ? ? ? ? "Confirm" : function() {
? ? ? ? ? ? ? ? window.location.href = theHREF;
? ? ? ? ? ? },
? ? ? ? ? ? "Cancel" : function() {
? ? ? ? ? ? ? ? $(this).dialog("close");
? ? ? ? ? ? }
? ? ? ? });
? ? ? ? $("#dialog").dialog("open");
? ? });
});
希望這對其他人有所幫助,因為本文最初使我走上了正確的軌道,我認為我最好發布更正。

TA貢獻1875條經驗 獲得超5個贊
我為jquery ui確認對話框創建了自己的函數。這是代碼
function myConfirm(dialogText, okFunc, cancelFunc, dialogTitle) {
$('<div style="padding: 10px; max-width: 500px; word-wrap: break-word;">' + dialogText + '</div>').dialog({
draggable: false,
modal: true,
resizable: false,
width: 'auto',
title: dialogTitle || 'Confirm',
minHeight: 75,
buttons: {
OK: function () {
if (typeof (okFunc) == 'function') {
setTimeout(okFunc, 50);
}
$(this).dialog('destroy');
},
Cancel: function () {
if (typeof (cancelFunc) == 'function') {
setTimeout(cancelFunc, 50);
}
$(this).dialog('destroy');
}
}
});
}
現在在您的代碼中使用它,只需編寫以下內容
myConfirm('Do you want to delete this record ?', function () {
alert('You clicked OK');
}, function () {
alert('You clicked Cancel');
},
'Confirm Delete'
);
繼續。
- 3 回答
- 0 關注
- 517 瀏覽
添加回答
舉報