Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS 5中不推荐使用Ext.EventManager_Javascript_Extjs_Extjs4_Extjs5 - Fatal编程技术网

Javascript ExtJS 5中不推荐使用Ext.EventManager

Javascript ExtJS 5中不推荐使用Ext.EventManager,javascript,extjs,extjs4,extjs5,Javascript,Extjs,Extjs4,Extjs5,在ExtJS5中,我得到控制台警告说 [W] Ext.EventManager已弃用。使用Ext.dom.Element#addListener 附加事件侦听器 我使用下面的代码语句 Ext.EventManager.on(window, 'beforeunload', function() { //code here }); 我知道Ext.EventManager已被弃用,但我应该如何替换我的code语句以在extjs5中使用它?使用getWin()方法并使用在上附加事件处理程序 E

在ExtJS5中,我得到控制台警告说

[W] Ext.EventManager已弃用。使用Ext.dom.Element#addListener 附加事件侦听器

我使用下面的代码语句

Ext.EventManager.on(window, 'beforeunload', function() {
    //code here
});
我知道
Ext.EventManager
已被弃用,但我应该如何替换我的code语句以在extjs5中使用它?

使用
getWin()
方法并使用
上附加事件处理程序

Ext.getWin().on('beforeunload',function(){ 
   //code here
});
其他可能的选择是使用纯JavaScript

window.onbeforeunload = function(){
    //Code here
};  
只要做:

Ext.getWin().[m]on('beforeunload', function() {
    //code here
});
你可能会发现你自己也在这个世界上。形成文件:

在DOM元素上注册事件处理程序

此类已弃用。请使用Ext.dom.Element api附加 DOM元素的侦听器。例如:


window.on('beforeunload',function(){}
抛出控制台错误
uncaughttypeerror:window.on不是一个函数
window
是本机DOM元素;
Ext.getWin()
返回ExtJS包装器。Thx,Robert。编辑我的答案更准确:)BTW.Replacement for
Ext.EventManager.on(文档,'keydown',…
是('keydown',…
上的
Ext.getDoc()。
var element = Ext.get('myId');

element.on('click', function(e) {
    // event handling logic here
});