我希望在某个操作时禁用所有页面元素.就像 JQuery UI 中的 modal 功能一样.
I wish to disable all page elements upon an action. Like the modal feature that is in the JQuery UI.
就像 ajax 动作一样.我希望显示通知,同时启用模态功能.并且请求后,需要重新启用页面元素回来.
Like on an ajax action.. I wish to show a notification and at the same time to enable the modal feature. And after the request, need to re-enable the page elements back.
在核心 jquery 中是否有任何可用的选项或任何插件?
Is there any option available in core jquery for that or any plugins?
页面元素没有被禁用 - 这样做会很乏味 - 而是在顶部覆盖了一个半透明的 div
所有其他页面元素.为此,您可能会执行类似
The page elements are not disabled - doing that would be quite tedious - but rather, a semi-transparent div
is overlayed on top of all other page elements. To do this, you would probably do something like
// Declare this variable in the same scope as the ajax complete function
overlay = $('<div></div>').prependTo('body').attr('id', 'overlay');
还有 CSS:
#overlay {
position: fixed;
height: 100%;
width: 100%;
z-index: 1000000;
background: url('link/to/semitransparent.png');
}
然后,一旦操作完成,您只需像这样删除它:
Then once the action is complete, you simply remove it like this:
overlay.remove();
如果这是您唯一需要的,则无需包含 jQuery UI.
No need to include jQuery UI if this is the only thing you need it for.
这篇关于使用 jquery 禁用所有具有模式功能的页面元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!