禁用BlockUI某些Ajax调用 [英] Disable BlockUI for certain ajax calls

查看:656
本文介绍了禁用BlockUI某些Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用的辉煌BlockUI,并使用默认的设置它

I am using the brilliant BlockUI, and have set it up using the default

$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);

这是伟大的 - 除非我添加了页面上的自动完成功能的元素,然后blockUI在踢,一旦用户开始输入。而不是明确设置什么是AJAX调用,启动块UI任何人都可以想出一个方法来禁用blockUI某些AJAX功能?

Which is great - except when I add a autocomplete element on the page, and then the blockUI kicks in as soon as the user starts typing. Rather than explicitly set what ajax calls to launch the block UI can anyone think of a way to disable blockUI for certain ajax functions?

推荐答案

您可以做这样的事情:

var dontBlock = false;

$(document).ajaxStart(function(){
    if(!dontBlock)
        $.blockUI();
}).ajaxStop($.unblockUI);

// And in the ajax methods (to be excluded), set dontBlock accordingly

$('#autocomplete').keydown(function(){
    dontBlock = true;
    $.ajax({
        // url, data etc.
        success: function(){ dontBlock = false; }
    });
});

这篇关于禁用BlockUI某些Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆