javascript Sencha touch 应用程序加载掩码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7749970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 01:10:23  来源:igfitidea点击:

Sencha touch application loading mask

javascriptsencha-touch

提问by neolaser

I have a sencha touch application, but want to apply a loading mask to the entire app while the page is loading. (i.e. while the Javascript files etc are loading)

我有一个 sencha touch 应用程序,但想在页面加载时将加载掩码应用于整个应用程序。(即当 Javascript 文件等正在加载时)

In ExtJS, I used to have a full sized div with a loading image, then as the first action of the "onReady" I used to fade that div out then remove it. Unfortunately, fadeOut() doesnt seem to be available in SenchaTouch

在 ExtJS 中,我曾经有一个带有加载图像的全尺寸 div,然后作为“onReady”的第一个动作,我用来淡出该 div 然后将其删除。不幸的是, FadeOut() 在 SenchaTouch 中似乎不可用

My app definition is as follows:

我的应用定义如下:

Ext.application({
    name: 'MyApp',

    launch: function() {
        Ext.create('Ext.Panel', {
            fullscreen: true,
            html: 'Hello World'
        });
    }
});

Any pointers would be appretiated

任何指针都会被appretiated

回答by Abdel Raoof

You can make use of the Ext.LoadMask class. There is an example:

您可以使用 Ext.LoadMask 类。有一个例子:

var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
myMask.show();

When you finish loading some Ajax requests or doing your task and to remove the mask, you can:

当您完成加载一些 Ajax 请求或完成您的任务并移除掩码后,您可以:

myMask.hide();

回答by Nilanchal

Hey you can also try this below code while doing ajax request and loading data

嘿,您也可以在执行 ajax 请求和加载数据时尝试以下代码

var mask = new Ext.LoadMask(Ext.getBody(), {msg:"wait msg..."});                


                Ext.Ajax.on('beforerequest', function(){        

                        mask.show();
                });


                Ext.Ajax.on('requestcomplete', function(){      

                        mask.hide();
                });             


                Ext.Ajax.on('requestexception', function(){         

                });

回答by Tyler K

Here is how I go about it:

这是我的方法:

Ext.getBody().mask().addCls('black-background');

.black-background {
  opacity: 1;
  background: black;
}