jquery 中 .blockUI 的简单示例

发布于 2024-08-09 08:42:03 字数 36 浏览 5 评论 0原文

请通过一个简单的演示来引导我了解 blockUI 的用途。

Please guide me to the purpose of blockUI with a simple demonstration.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

月下凄凉 2024-08-16 08:42:03

查看插件页面上的演示

您需要在页面中包含以下内容(按此顺序)

  1. 添加对 jQuery core 脚本
  2. 添加对 阻止 UI 脚本
  3. 在需要时添加实现覆盖所需的 jQuery 代码

Take a look at the demos on the plugin page.

You need to do have the following in a page (in this order)

  1. Add a reference to the jQuery core script
  2. Add a reference to the Block UI script
  3. Add the jQuery code required to achieve the overlay when it is required
弥繁 2024-08-16 08:42:03

要从此链接创建一个js文件 jquery.blockUI.js 并将其放入您的项目,其中 js 文件包含

并在 html 中编写此代码:

    <div id="throbber" style="display:none;">
        <img src="/static/image/gears.gif" /><h4>Please..</h4>
    </div>
    {% block customjs %}
    <script type="text/javascript">
        $(document).ajaxStop($.unblockUI);
        $(document).ready(function() {
    $.blockUI({ message:$('#throbber') }); 
       });
    </script>

这是一个简单的演示。也许它会对您有所帮助

添加对 jquery.blockUI.js

To create a js file jquery.blockUI.js from this link.and put it into your project where the js files inclu

and in html write this code:

    <div id="throbber" style="display:none;">
        <img src="/static/image/gears.gif" /><h4>Please..</h4>
    </div>
    {% block customjs %}
    <script type="text/javascript">
        $(document).ajaxStop($.unblockUI);
        $(document).ready(function() {
    $.blockUI({ message:$('#throbber') }); 
       });
    </script>

This is a simple demonstration.May be it will be helps to you

Add a reference to the jquery.blockUI.js

梦忆晨望 2024-08-16 08:42:03
<script type="text/javascript">
$(document).ready(function() { 
    $('#demo10').click(function() { 
        $.blockUI({ 
            message: '<h1>Auto-Unblock!</h1>', 
            timeout: 2000 
        }); 
    }); 
}); 
</script>
<script type="text/javascript">
$(document).ready(function() { 
    $('#demo10').click(function() { 
        $.blockUI({ 
            message: '<h1>Auto-Unblock!</h1>', 
            timeout: 2000 
        }); 
    }); 
}); 
</script>
伊面 2024-08-16 08:42:03

我刚刚得到了阿德里安·布兰德的帮助并使其发挥作用......
因此,如果其他人正在寻找工作示例:

function block() {
  $.blockUI();
  setTimeout(unBlock, 5000); 
}

function unBlock() {
  $.unblockUI();
}

function alertUser() {  
  alert('Alert User'); 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.js"></script>

<button onclick="alertUser()">Alert</button>
<button onclick="block()">Block!</button>
<button onclick="unBlock()">UnBlock!</button>

I just got help from Adrian Brand and made it work...
So if anyone else is looking for a working sample:

function block() {
  $.blockUI();
  setTimeout(unBlock, 5000); 
}

function unBlock() {
  $.unblockUI();
}

function alertUser() {  
  alert('Alert User'); 
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.js"></script>

<button onclick="alertUser()">Alert</button>
<button onclick="block()">Block!</button>
<button onclick="unBlock()">UnBlock!</button>

荒芜了季节 2024-08-16 08:42:03

主页

jQuery BlockUI 插件让您
模拟同步行为
使用 AJAX,无需锁定
浏览器1。激活后,它将
阻止用户对该页面进行活动
(或页面的一部分)直到
已停用。 BlockUI 将元素添加到
DOM 给它两个
阻塞的外观和行为
用户交互。

如果您想要使用 ajax,但还想在发生长 ajax 请求时阻止用户输入,那么 BlockUI 适合您。

From the homepage:

The jQuery BlockUI Plugin lets you
simulate synchronous behavior when
using AJAX, without locking the
browser1. When activated, it will
prevent user activity with the page
(or part of the page) until it is
deactivated. BlockUI adds elements to
the DOM to give it both the
appearance and behavior of blocking
user interaction.

If you want to have ajax, but you also want to block user input while a long ajax request is happening, then BlockUI is for you.

╭ゆ眷念 2024-08-16 08:42:03

这是一个非常基本的例子:

<!DOCTYPE html>
<html>
<head>
    <title>Jquery BlockUi Plugin</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="http://malsup.github.io/jquery.blockUI.js" type="text/javascript"></script>
</head>
<body>
    <button class="btn">
        Click me to block UI
    </button>

</body>
<script type="text/javascript">
    $('.btn').click(function(argument) {
        $.blockUI({message:"Ui is blocked"});
        setTimeout($.unblockUI,2000)
    })
</script>

</html>

Here is a very basic example:

<!DOCTYPE html>
<html>
<head>
    <title>Jquery BlockUi Plugin</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
    <script src="http://malsup.github.io/jquery.blockUI.js" type="text/javascript"></script>
</head>
<body>
    <button class="btn">
        Click me to block UI
    </button>

</body>
<script type="text/javascript">
    $('.btn').click(function(argument) {
        $.blockUI({message:"Ui is blocked"});
        setTimeout($.unblockUI,2000)
    })
</script>

</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文