我想在 UI 工具包中使用简单模态或对话框插件之类的插件。但是,我如何使用这些或任何其他并获得结果。基本上我希望模态与服务器进行一些 AJAX 交互并返回调用代码的结果以执行一些操作。
最佳答案
这是确认窗口在 simpleModal 上的工作方式:
$(document).ready(function () {
$('#confirmDialog input:eq(0)').click(function (e) {
e.preventDefault();
// example of calling the confirm function
// you must use a callback function to perform the "yes" action
confirm("Continue to the SimpleModal Project page?", function () {
window.location.href = 'http://www.ericmmartin.com/projects/simplemodal/';
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
close: false,
overlayId: 'confirmModalOverlay',
containerId: 'confirmModalContainer',
onShow: function (dialog) {
dialog.data.find('.message').append(message);
// if the user clicks "yes"
dialog.data.find('.yes').click(function () {
// call the callback
if ($.isFunction(callback)) {
callback.apply();
}
// close the dialog
$.modal.close();
});
}
});
}
关于javascript - 我如何从 jQuery 中的模态对话框中获取结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50097/