JQuery 忙线指示器不禁用键盘事件



我已经集成了一个Jquery繁忙指示器在我的应用程序从这个链接:http://www.aspsnippets.com/demos/1331/

它不允许用户在加载时点击输入元素。但是如果我按tab键,我可以很容易地导航到这些输入元素,输入我想要的任何东西,然后按回车键发送服务呼叫。这就违背了占线指示器的全部目的。知道我该怎么修吗?

css:

.busy-modal
    {
        position: fixed;
        z-index: 999;
        height: 100%;
        width: 100%;
        top: 0;
        left: 0;
        background-color: Black;
        filter: alpha(opacity=60);
        opacity: 0.6;
        -moz-opacity: 0.8;
    }
    .busy-center
    {
        z-index: 1000;
        margin: 300px auto;
        padding: 10px;
        width: 130px;
        background-color: White;
        border-radius: 10px;
        filter: alpha(opacity=100);
        opacity: 1;
        -moz-opacity: 1;
    }
    .busy-center img
    {
        height: 128px;
        width: 106px;
    }

我通过手动禁用繁忙指示器上的键盘输入来修复它。我是这样做的:

在我的angularJS控制器中,我声明了一个变量来决定是否禁用键盘输入

$scope.disableKeys = false;

然后我添加了以下代码来禁用键盘输入

window.addEventListener('keydown', function (event) {
    if ($scope.disableKeys == true) {
        event.preventDefault();
        return false;
    }
});

这是我的busyIndicator函数:

function busyIndicator(type)
{
    if(type == 1)
    {           
        $scope.disableKeys = true;
        $(".busy-modal").show();
    }
    else if (type == 0)
    {
        $scope.disableKeys = false;
        $(".busy-modal").hide();
    }
}

最后调用这个函数:

//to show busy indicator
busyIndicator(1);
//to hide busy indicator
busyIndicator(0);

最新更新