如何从JQuery中的模式对话框中获取结果
时间:2020-03-05 18:49:27 来源:igfitidea点击:
我想在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(); }); } }); }