2011-06-02 56 views
3

我正在为我的应用程序使用Extjs。当extjs完全加载应用程序(图像和所有内容)时,哪个事件/侦听器被触发?extjs 3 - 当extjs完全加载时会触发哪个事件

我试着以下但这些工作的:

  • 机构或窗口的onload(body标签是空的)
  • 视口渲染听众

我目前在做什么:当我启动它显示“加载”掩码的应用程序。然后ajax请求被触发,当它完成时,“加载”掩码被删除。以下可能会给一些想法:

Ext.onReady(function(){ 
    Ext.ux.mask = new Ext.LoadMask(Ext.getBody(), {msg: "Loading..."}); 
    Ext.ux.mask.show(); // Show the mask 

    // All components are loaded eg. viewport, tabpanel, button etc... 
    ajax_request(); // Somewhere between the code ajax request is called 
    // All components are loaded eg. viewport, tabpanel, button etc... 

    function ajax_request() { 
     // Other processing 

     Ext.ux.mask.hide(); // Hide the mask 
    } 
}); 

的问题是Ajax请求是需要很长时间,所以我现在想换工作的东西如下:

Ext.onReady(function(){ 
    Ext.ux.mask = new Ext.LoadMask(Ext.getBody(), {msg: "Loading..."}); 
    Ext.ux.mask.show(); // Show the mask 

    // All components are loaded eg. viewport, tabpanel, button etc... 
    ajax_request(); // Somewhere between the code ajax request is called 
    // All components are loaded eg. viewport, tabpanel, button etc... 

    function ajax_request() { 
     // Other processing 

     //Ext.ux.mask.hide(); // Hide the mask - removed 
    } 

    // I want to call this when everything is loaded on the page 
    function everything_loaded() { 
     Ext.ux.mask.hide(); // Hide the mask 
    } 

}); 

任何想法,对此有何看法?非常感谢您的帮助。

+0

为什么不使用'Ext.onReady'? – 2011-06-03 02:37:39

+0

In Ext。onReady()所有的组件都被加载,但它们并不是100%的工作状态,在Ext.onReady – user427969 2011-06-03 02:44:45

+0

的最后一条语句中,你是否试图加载自己的图像等?然后在所有组件加载时使用ext? – 2011-06-03 02:52:28

回答

0

感谢AMOL和Warung Nasi 49.虽然我找不到最好的方法,但我设法得到几乎预期的结果:

Ext.onReady(function(){ 
    Ext.ux.mask = new Ext.LoadMask(Ext.getBody(), {msg: "Loading..."}); 
    Ext.ux.mask.show(); // Show the mask 

    // All components are loaded eg. viewport, tabpanel, button etc... 

    setTimeout(function(){ 
     Ext.ux.mask.hide(); 
    }, 2000); 

}); 
3

你指的是什么ExtJs版本? 3.x还是4.x?

如果是4.x,请考虑使用/遵循MVC Application Architecture准则。在这种情况下,你要在MVC Application ArchitectureExt.app.Application

描述如果3.x中,我猜Ext.onReady()是他们有最好的覆盖Ext.application.launch

UPDATE

基于更新后的问题,这是你在找什么 -


Ext.onReady(function(){ 
    Ext.Ajax.on('beforerequest', showSpinner, this); 
    Ext.Ajax.on('requestcomplete', hideSpinner, this); 
    Ext.Ajax.on('requestexception', hideSpinner, this); 
... 
}); //end of onReady 

showSpinner = function(){ 
    //setup and show mask 
} 

hideSpinner = function(){ 
//hide mask 
} 

参考 - 您的更新Ext.Ajax

+0

嗨,感谢您的回复。我已更新我的问题以反映我想要的内容。问候 – user427969 2011-06-06 01:05:48

+0

更新了答案。这也具有(UI)正在使用时自动显示和隐藏任何ajax调用的遮罩的(良好的)副作用。 – 2011-06-06 16:46:21

2

基地....我得到的结论您使用的是Ext 3.xx版本

当我启动应用程序它会显示“加载”掩码。然后一个Ajax请求被触发,当它完成,“加载”面罩去除

你怎么叫AJAX?你为什么不在ajax回调中隐藏面具?

Ext.Ajax.request({ 
    url : "blabla", 
    method : "GET", 
    callback : function(){ 
     Ext.ux.mask.hide(); 
    } 
}); 

,或者mybe你想尝试这个one(这是我用来显示预载)

+0

嗨,谢谢你的回复。目前我只在callback()方法中隐藏了掩码,但是我的ajax请求很耗时,所以我不想等那么久。此外,我试过链接,但我不能使用那个因为我在身体上使用面具,所以它隐藏了身体。问候 – user427969 2011-06-06 04:34:55

0

尝试afterlayout事件,并指定一个方法来执行时,它的trigered

相关问题