并发调用 simplemodal 对象
我必须使一个函数与多个打开/关闭模式请求并发。
例如:当我调用 showAjaxLoading(true) 时,它会显示模式,而 showAjaxLoading(false) 则会处理模式。
问题:当我发出第一个长请求来显示模式时,另一个快速请求将关闭它。我希望能够将所有请求保留在数组中,并仅在最后一个请求结束时才处理模式。
SimpleModal:对象 simplemodal 是唯一的。当您创建模态时,它返回对象本身。但是当你已经打开了一个模态框时,它会返回 false。 url: http://www.ericmmartin.com/projects/simplemodal/
var showAjaxLoading = function (show) {
var ajaxModal;
if (show) {
var aModal = $("#ajaxLoading").modal({ overlayId: 'ajaxloading-overlay', containerId: 'ajaxloading-container', closeClass: 'ajaxloading-close', close: false, escClose: false });
if (aModal !== false) {
ajaxModal = aModal;
};
} else {
if (ajaxModal !== undefined && $.isFunction(ajaxModal.close)) {
ajaxModal.close();
};
};
};
这是什么解决这个问题的最佳方案是什么?
I have to make a function concurrent to multiple open/close modal requests.
For exemple: When i call showAjaxLoading(true), it's showing the modal, and showAjaxLoading(false) it's disposing the modal.
The Problem: When i make a first long request to showing the modal, and another one quick request will close it. I want to be able keeping in a array all the requests and disposing the modal only when the last request is ended.
SimpleModal: The object simplemodal is unique. When you create the modal it return the object itself. But when you have a modal already open, it returns false. url: http://www.ericmmartin.com/projects/simplemodal/
var showAjaxLoading = function (show) {
var ajaxModal;
if (show) {
var aModal = $("#ajaxLoading").modal({ overlayId: 'ajaxloading-overlay', containerId: 'ajaxloading-container', closeClass: 'ajaxloading-close', close: false, escClose: false });
if (aModal !== false) {
ajaxModal = aModal;
};
} else {
if (ajaxModal !== undefined && $.isFunction(ajaxModal.close)) {
ajaxModal.close();
};
};
};
What the is the best solution to solve this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样的操作/现在,您可以在每次发出 AJAX 请求时调用 modalDialog.showAjaxLoading() ,并在每次请求完成时调用 modalDialog.hideAjaxLoading() 。
Try something like this/ Now you can call modalDialog.showAjaxLoading() each time you making AJAX request and modalDialog.hideAjaxLoading() each time your request is completed.