一定要将全局定义名称在function外面,不然其它地方就访问不了呀。搞到我一头雾水!
附上代码:
var panel; function showAddPanel() { if (!panel) { panel = new Ext.Window( { id:'panel', el : 'panel', layout : 'fit', width : 600, height : 500, closeAction : 'hide', plain : true, items : new Ext.TabPanel( { region : 'center', border : false, activeTab : 0, items : [ { title : '客户信息', autoScroll : true, items : [afm] }, { title : '合作项目', autoScroll : true }, { title : '相关报价', autoScroll : true }, { title : '相关订单', autoScroll : true }] }), buttons : [ { text : '保存' }, { text : '重置' }, { text : '关闭', handler : function() { panel.hide(); } }] }); } panel.show(this); }