帮忙看看这段代码~!

fuyun 2008-09-05
代码如下:(代码有点长,还请大家耐心看完~谢谢~!^_^)

Ext.extend(namespace.Module,{
  init:function(){//初始化
    ...,
    success:this.loadTreeRootFinish
  },
  loadTreeRootFinish:function(){//获取根节点
    ...;
    this.treeToolBar = new Ext.Toolbar(...);//树工具栏
    this.groupTree = new Ext.tree.TreePanel(...);//树
    this.contactStore = new Ext.data.JsonStore({...});//store
    this.userCM = new Ext.grid.ColumnModel(...);//列模型
    this.paging = new Ext.PagingToolBar({...});//分页工具栏
    this.gridToolBar = new Ext.ToolBar([{//工具栏
        ...,
        scope:this,
        handler:this.addContact
      },'-',
        ...
    ]);
    this.contactGrid = new Ext.grid.GridPanel({
      ...,
      store:this.contactStore,
      ...
    });
    this.bodyPanel = new Ext.Panel({
      ...,
      items:[this.contactGrid]
    });
    this.mainPanel = new Ext.Panel({
      ...,
      items:[this.groupTree,this.bodyPanel]
    });
    this.main.add(this.mainPanel);
    this.main.doLayout();
    ...;
    this.groupTree.on("click",function(...){...},this);
  },
  addContact:function(){//增加联系人
    ...;
    this.contactInfoManage(...);
  },
  ...,
  contactInfoManage:function(...){
    contactInfoWindow = new Ext.Window({...});
    ...;
    contactInfoWindow.addButton("确定", this.contactInfoAdd);//问题一:该种写法能够打开新的窗口,但新窗口的表单提交按钮点击没有反应;若改为contactInfoWindow.addButton("确定",function(){contactInfoAdd()});则没有问题,表单能够正常提交
    contactInfoWindow.addButton("取消", function() {closeWindow(contactInfoWindow)}, this);
    contactInfoWindow.show(...,function(){
      ...;
      Ext.Ajax.request({
        method:'GET',
        ...,
        scope:this,
        success:function(response){
          loadContactInfoFormFinish(response);
        }
      });
    },this);
    ...;
    function loadContactInfoFormFinish(response){
      ...;
    }
    function contactInfoAdd(){//问题关键在这个方法
      if (!contactInfoFormPanel) //表单对象还没有加载完成
        return;
      if (!contactInfoFormPanel.form.isValid())
        return;
      contactInfoFormPanel.form.submit({
        waitTitle:...,
        waitMsg:...,
        url:...,
        method:'post',
        params:{...},
        scope:this,
        success:function(object,action){
          Ext.Msg.show({...});
          closeWindow(contactInfoWindow);
          //this.contactStore.reload();//问题二:去掉此句,一切正常,运行此句,提示contactStore为空或未定义
        },
        ...
      });
    }
  }
});

如代码中所描述的,问题一、二分别是什么原因,该怎么解决,另外,在代码中,该如何获取前面定义的contactStore,然后进行reload()?
Global site tag (gtag.js) - Google Analytics