EXTJS在使用中遇到的问题

来源:互联网 发布:御剑封天源码 编辑:程序博客网 时间:2024/05/01 23:25

EXTJS在使用中出现的疑问

1.       代码如下:

success : function(LoginForm, action) { 

                if(typeof(action.result.strStatus)!="undefined"){

                    if(action.result.strStatus=="0000"){

                        window.location.href ='./MainForm.jsp';

                    }else{

                        Ext.Msg.alert('提示', action.result.result);}

                }else{

                    Ext.Msg.alert('提示',"后台查询错误!");

                }

            },  

failure : function(LoginForm, action) {

              Ext.MessageBox.alert('警告',"用户名、密码验证失败!");

              LoginForm.getForm().reset(); 

          }

运行以后,LoginForm.getForm().reset();不能正确的执行.

前面一句代码Ext.MessageBox.alert('警告',"用户名、密码验证失败!");能正确执行

 

原因分析:

    由于function(LoginForm, action){}中的LoginForm就是指一个form参数,其实该参数代表的就是LoginForm就是LoginForm.getForm();所以正确的写法应该如下:

success : function(form, action) { 

                if(typeof(action.result.strStatus)!="undefined"){

                    if(action.result.strStatus=="0000"){

                        window.location.href ='./MainForm.jsp';

                    }else{

                        Ext.Msg.alert('提示', action.result.result);}

                }else{

                    Ext.Msg.alert('提示',"后台查询错误!");

                }

            },  

failure : function(form, action) {

              Ext.MessageBox.alert('警告',"用户名、密码验证失败!");

              form.reset(); 

          }

这样就能正确执行了,从这里我们可以更清楚的发现,其实参数form就是LoginForm.getForm();

从代码规范的角度来看,我们鼓励参数已小写字母开头来写,采取驼峰式写法。这样就能很清楚的看出问题

 

原创粉丝点击