本帖最后由 pywepe 于 2010-09-08 11:33:30 编辑

解决方案 »

  1.   

    fk fk csdn的编辑器真lj  颜色显示不出来 
      

  2.   

    function LoginWindow(){
    var me=this;
    .............
    }
    然后调用改成me.form.getForm().submit,试下能不能行。
      

  3.   

    把这个form.getForm().submit({
    换成:this.form.getForm().submit({
    试一下。
      

  4.   

    handler:function(){ 
                             this.getForm().submit({ //错误form未定义.  
                                                 //我是想调用类LoginWindow的form属性的,这样不行,那么要怎么调呢?
                                    success:function(form,action){
                                       echatMgr.toMain(this);
                                    },
                                    failure:function(form,action){
                                       
                                    }
                                });
                            }
    直接this.getForm()看看
      

  5.   

    函数开头加上var me=this;这个时候this引用对象LoginWindow。
      

  6.   

    改造一下Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = "title";
    LoginWindow = Ext.extend(Ext.Window, {
        title: "登录",
        width: 280,
        height: 210,
        frame: true,
        plain: true,
        resizable: false,
        minimizable: false,
        maximizable: false,
        collapsible: true,
        border: false,
        defaults: {
            border: false
        },
        buttonAlign: "center",
        createFormPanel: function() {
            return new Ext.form.FormPanel({
                bodyStyle: "padding-top:6px ",
                defaultType: "textfield",
                labelAlign: "right",
                labelWidth: 60,
                labelPad: 0,
                frame: true,
                defaults: {
                    allowBlank: false,
                    width: 158
                },
                items: [{
                    id: "",
                    name: "",
                    fieldLabel: "",
                    blankText: ""
                },
                {
                    id: "",
                    name: "",
                    fieldLabel: "",
                    blankText: ""
                },
                {
                    id: "",
                    name: "",
                    fieldLabel: "",
                    blankText: "",
                    inputType: ""
                }]
                });
            },
            login: function() {
                var This = this;
                if (this.fp.form.isValid()) {
                    this.fp.form.submit({
                        waitMsg: "正在登录......",
                        clientValidation: true,
                        url: "LoginHandler.ashx",
                        params: { action: "UserLogin" },
                        success: function(form, action) {                    },
                        failure: function(form, action) {                    }
                    });
                }
            },
            listeners: {
                render: function(win) {
                    win.fp.form.waitMsgTarget = win.getEl();
                }
            },
            //初始化窗口
            initComponent: function() {
                LoginWindow.superclass.initComponent.call(this);
                this.fp = this.createFormPanel();
                this.add(this.fp); //将form表单加入到window中
                this.addButton({ id: "btnLogin", name: "btnLogin", text: "登录" }, this.login, this);
                this.addButton("重置", function() { this.fp.form.reset(); }, this);
            }
        });    Ext.onReady(function() {
            var win = new LoginWindow();
            win.show();
        });
      

  7.   


    LoginWindow = Ext.extend(Ext.Window, {}); //这句是产生一个子类LoginWindow  然后{}里写的东西是什么意思呢?  传给Window ??? 不太懂
    Ext.form.Field.prototype.msgTarget = "title";  //这句就更不懂了 不懂js的这种语法  请指教  也不用太深 能达到我的需求就好 
      

  8.   

     form.getForm().submit({ //错误form未定义.  你form没有指定明显是哪个哦
      

  9.   

    猜测楼主的意思,2楼应该答道点子上了。
    function outer() {
        this.prop = 'outer';
        var outerObj = this; // 声明变量outerObj引用外部this
        function inner() {
            this.prop = 'inner';
            alert('this.prop: ' + this.prop); // 外部this被闭包内部this覆盖
            alert('outerObj.prop: ' + outerObj.prop); // 但可以用外部声明的变量outerObj代替。
        }
        new inner();
    }
    new outer();
      

  10.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>MyHtml.html</title>

        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=gbk">
        <link rel="stylesheet" type="text/css" href="ext-3.2.1/resources/css/ext-all.css" />
        <script type="text/javascript" src="ext-3.2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="ext-3.2.1/ext-all.js"></script>
    <script type="text/javascript">
       function LoginWindow(){
            
                //this.state = LOGIN_STATE_READY; //当前状态:准备登录
                
                
                this.form = new Ext.form.FormPanel({
                    title:" 登录",
                    defaultType:"textfield",
                    labelWidth:45,
                    items:[
                        {
                           fieldLabel:"用户名",
                           name:"name"
                        },
                        {
                           fieldLabel:"密  码",
                           inputType:"password",
                           name:"passwd"
                        }
                    ],
                    buttons:[
                        {
                            text:"登录",
                            handler:function(){ 
                             alert(this.form.getForm().getValues(true));
                              this.getForm().submit({ //错误form未定义.  /*用this,这样就可以了*/
                                                 //我是想调用类LoginWindow的form属性的,这样不行,那么要怎么调呢?
                                    success:function(form,action){
                                       echatMgr.toMain(this);
                                    },
                                    failure:function(form,action){
                                       alert("error");
                                    }
                                });
                            },
                            scope: this//添加handler函数的作用域,this指向当前的LoginWindow对象
                        },
                        {
                           text:"注册",
                           handler:function(){
                               
                           }
                        }
                    ],
                    url:'LOGIN_WINDOW_POST_URL',
                    
                });
                
                this.win = new Ext.Window({
                    title:"LOGIN_WINDOW_TITLE",
                    width:400,
                    height:300,
                    constrain:true,
                    layout:"fit"
                });            
                
                this.win.add(this.form); 
    this.win.show();          
            }
            
            Ext.onReady(function () {
             LoginWindow();
            });
    </script>
      </head>
      
      <body>
      </body>
    </html>
    handler:function(){ 
                             alert(this.form.getForm().getValues(true));
                              this.getForm().submit({ //错误form未定义.  /*用this,这样就可以了*/
                                                 //我是想调用类LoginWindow的form属性的,这样不行,那么要怎么调呢?
                                    success:function(form,action){
                                       echatMgr.toMain(this);
                                    },
                                    failure:function(form,action){
                                       alert("error");
                                    }
                                });
                            },
                            scope: this
    不用改动大,加一个scope:this 然后用this.form.getForm()就可以得到form对象了
    测试通过
      

  11.   

    Ext.extend是ext的继承机制,从名字就应该很容易看出来,LoginWindow是子类,Ext.Window父类,{}中的是子类属性和方法,如果有和父类一样的,那么覆盖。具体的用法google或者百度,很多。Ext.form.Field.prototype.msgTarget = "title"; //这句就更不懂了form是Ext对象一个成员,Field是form对象的一个成员,依次类推,其中prototype(原型)有些特殊,有兴趣可以阅读下http://blog.csdn.net/niuyongjie/archive/2009/11/15/4810835.aspx#
    至于楼主的问题“错误form未定义”根本不用多麻烦,我#2应该就能解决了。关于this的文章http://topic.csdn.net/u/20090217/13/653f7949-9e0c-4e99-adb3-dcbc99fca8d5.html