Fed*_*riz 0 extjs dom-events extjs4.1
我正在使用ext js 4.1.我正在开发一个应用程序,必须支持IE9,最新的FF,最新的Chrome和Safari.
如果有一些数据待提交,我需要在用户想要离开时显示警告消息.
我使用原始java脚本执行了以下操作
window.onbeforeunload=function(){
if (Ext.getStore('LocalChangesStore')){
if (Ext.getStore('LocalChangesStore').getCount() > 0) {
return 'Your changes are be lost.';
}
}
};
Run Code Online (Sandbox Code Playgroud)
我想知道是否可以使用ext js.我看到了以下功能
app.js:
EventManager.onWindowUnload( function(){
if (Ext.getStore('LocalChangesStore')){
if (Ext.getStore('LocalChangesStore').getCount() > 0) {
return 'Your changes are be lost.';
}
}
}, this
);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
有人可以告诉我哪种方法可以解决这个问题.
在此先感谢费德里科
该onWindowUnload方法attachs一个函数来卸载事件,但你需要的是附加功能的beforeunload事件.请试试这个
Ext.EventManager.on(window, 'beforeunload', function() {
return 'Your changes are be lost.';
});
Run Code Online (Sandbox Code Playgroud)
祝好运.
| 归档时间: |
|
| 查看次数: |
3459 次 |
| 最近记录: |