1

有谁知道如何在 ExtJS MVC 应用程序中注册窗口卸载事件。

Ext.EventManager.on(window, 'beforeunload', function() {
alert('cross-exit tab click AND cross-exit browser click');});

上面的代码需要放在一个javascript文件中。我不确定哪个文件应该包含上述代码。

4

2 回答 2

1
window.onbeforeunload = function() {
return "You have made changes, are you sure you would like to navigate away from the page?";}.bind(this);

上面的代码完成了这项工作。我把它放在我的主控制器下。

于 2012-05-22T11:51:07.587 回答
0

将它放在 init 方法内部的控制器中:

init: function(){

Ext.EventManager.on(window, 'beforeunload', function() {
    this.setAllValues(false);
});

this.control({
............
....
于 2012-10-18T17:32:58.750 回答