使用场景:关闭window的时候增加监听事件。
正确的使用方式:

Code
1 Ext.onReady(function(){
2 var win;
3 var button = Ext.get('show-btn');
4
5 button.on('click', function(){
6 // create the window on the first click and reuse on subsequent clicks
7 if(!win){
8 win = new Ext.Window({
9 applyTo : 'hello-win',
10 layout : 'fit',
11 width : 500,
12 height : 300,
13 closeAction :'hide',
14 plain : true,
15 listeners : {'hide':{fn: makesure}},
16 modal:true,
17 items : new Ext.TabPanel({
18 applyTo : 'hello-tabs',
19 autoTabs : true,
20 activeTab : 0,
21 deferredRender : false,
22 border : false
23 }),
24
25 buttons: [{
26 text : 'Submit',
27 disabled : true
28 },{
29 text : 'Close',
30 handler : function(){
31 win.hide();
32 }
33 }]
34 });
35 }
36 win.show(button);
37 });
38 function makesure(){
39 alert('close success');
40 }
41
42 });
html代码:

Code
1
<html>
2
<head>
3
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
4
<title>Hello World Window Example</title>
5
<link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/resources/css/ext-all.css" />
6
7
<!-- GC -->
8
<!-- LIBS -->
9
<script type="text/javascript" src="http://www.cnblogs.com/adapter/ext/ext-base.js"></script>
10
<!-- ENDLIBS -->
11
12
<script type="text/javascript" src="http://www.cnblogs.com/ext-all.js"></script>
13
14
<script language="javascript" src="lj-hello.js"></script>
15
16
<!-- Common Styles for the examples -->
17
<link rel="stylesheet" type="text/css" href="../shared/examples.css" />
18
19
<style type="text/css">
20
.x-panel-body p {
}{
21
margin:10px;
22
font-size:12px;
23
}
24
</style>
25
</head>
26
<body>
27
<script type="text/javascript" src="../shared/examples.js"></script><!-- EXAMPLES -->
28
29
<h1>Hello World Window</h1>
30
<p>This example shows how to create a very simple modal Window with "autoTabs" from existing markup.</p>
31
<input type="button" id="show-btn" value="Hello World" /><br /><br />
32
<p>Note that the js is not minified so it is readable. See <a href="hello.js">hellos.js</a> for the full source code.</p>
33
34
<div id="hello-win" class="x-hidden">
35
<div class="x-window-header">Hello Dialog</div>
36
<div id="hello-tabs">
37
<!-- Auto create tab 1 -->
38
<div class="x-tab" title="Hello World 1">
39
<p>Hello
</p>
40
</div>
41
<!-- Auto create tab 2 -->
42
<div class="x-tab" title="Hello World 2">
43
<p>
World!</p>
44
</div>
45
</div>
46
</div>
47
</body>
48
</html>
49
注意:关闭窗口使用hide方法。过使用close方法,在第二次通过button创建window的时候会报错。