在我的场景中,如果ajax调用超过500毫秒,我只想显示ExtJs.LoadMask
。它可以帮助应用程序显示出更快的响应速度和快速性,因为它可以减少加载..."快速ajax调用中的消息。 (并减少页面闪烁)。
在这种情况下,只有在响应时间超过500毫秒时才会显示LoadMask。
我认为最好的解决方案是覆盖Ext.LoadMask
类。但是下面的尝试没有成功:
Ext.override(Ext.LoadMask, {
msg: "Loading...",
timer: null,
initComponent: function () {
this.callParent(arguments);
this.timer = null;
},
listeners:{
beforeshow: function (animateTarget, callback, scope) {
loadMask = this;
this.timer =
setTimeout(function () {
loadMask.callParent(animateTarget, callback, scope);
}, 2000);
return x;
}
}
});
答案 0 :(得分:1)
经过数小时的调查,找到了解决方案(解决方案)。虽然它有点讨厌,但它有效!
Ext.override(Ext.LoadMask, {
msg: "Loading...",
timer: null,
initComponent: function () {
this.callParent(arguments);
this.timer = null;
this.isInShowProcess = false;
this.delay = 600; //in milliseconds
},
listeners: {
beforeshow: function (animateTarget, callback, scope) {
loadMask = this;
result = this.isInShowProcess != false;
if (!this.timer)
this.timer =
setTimeout(function () {
loadMask.isInShowProcess = true;
clearTimeout(loadMask.timer);
loadMask.timer = null;
loadMask.show(animateTarget, callback, scope);
loadMask.isInShowProcess = false;
}, this.delay);
return result;
},
beforehide: function (loadMask, eOpts) {
return loadMask.hideMask(loadMask, eOpts);
},
beforedestroy: function (loadMask, eOpts) {
return loadMask.hideMask(loadMask, eOpts);
}
},
hideMask: function (loadMask, eOpts) {
if (loadMask.timer) {//not shown yet
clearTimeout(loadMask.timer);
loadMask.timer = null;
}
return true;
}
});