1. #1
    Ext User
    Join Date
    Apr 2009
    Posts
    7
    Vote Rating
    0
    MechecksV is on a distinguished road

      0  

    Default I have a problem about Ext.getDOM

    I have a problem about Ext.getDOM


    Code:
    function LoginItems() {
        return [{
            xtype : 'textfield',
            fieldLabel : "用户名",
            id : 'UserID',
            name : 'UserID',
            allowBlank : false
        }, {
            xtype : 'textfield',
            fieldLabel : "密码",
            inputType : 'password',
            name : 'UserPassword',
            allowBlank : false
        }, {
            xtype : 'textfield',
            fieldLabel : "验证码",
            name: 'validateCode',
            style:"font-size: 15px",
            maxLength: 5,
            width: 80,
            allowBlank:false  
        }]
    }
    
    Login = function() {
        var win, form, submitUrl = '/user.mvc/login';  
        return {
            Init : function() {
            //    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
                var logoPanel = new Ext.Panel({
                    baseCls : 'x-plain',
                    id : 'login-logo',
                    region : 'center'
                });
    
                var formPanel = new Ext.form.FormPanel({
                    baseCls : 'x-plain',
                    defaults : {
                        width : 200
                    },
                    frame : false,
                    height : 100,
                    id : 'login-form',
                    items : LoginItems(),
                    labelWidth : 120,
                    region : 'south'
                });
                
                
                
                
                win = new Ext.Window({
                    buttons : [{
                        scope : Login,
                        text : "登陆",
                        handler : function CheckLogin() {
                            if (form.isValid()) {
                                var formvalue = form.getValues();
                                Ext.Ajax.request({
                                    url : submitUrl,
                                    method : "POST",
                                    waitMsg : "请等待!",
                                    params : {
                                        userid : formvalue.UserID,
                                        password : formvalue.UserPassword
                                    },
                                    success : function(response, options) {
                                        var responseMessage = Ext.util.JSON
                                                .decode(response.responseText);
                                        if (responseMessage.Result) {
                                            win.destroy();
                                            window.location = "/Home.mvc/Index";
                                        } else {
                                            Ext.MessageBox.alert("消息",
                                                    responseMessage.Message);
                                        }
                                    },
                                    failure : function(response, options) {
                                        Ext.MessageBox.hide();
                                        Ext.MessageBox.show({
                                            title :"登陆失败",
                                            msg : response.responseText
                                        });
    
                                    }
                                });
                            } else {
                                form.markInvalid();
                                Ext.MessageBox.alert("消息", "输入错误");
                            }
                        }
                    }],
                    buttonAlign : 'right',
                    closable : false,
                    draggable : false,
                    height : 250,
                    id : 'login-win',
                    layout : 'border',
                    minHeight : 250,
                    minWidth : 530,
                    plain : false,
                    resizable : false,
                    items : [logoPanel, formPanel],
                    title : 'Login',
                    width : 530
                });
    
                form = formPanel.getForm();
                win.show();
                
        
            }
            
        };
        
        
    }();
    
    
    Ext.BasicForm.prototype.afterAction = function(action, success) {
        this.activeAction = null;
        var o = action.options;
        if (o.waitMsg) {
            Ext.MessageBox.updateProgress(1);
            Ext.MessageBox.hide();
        }
        if (success) {
            if (o.reset) {
                this.reset();
            }
            Ext.callback(o.success, o.scope, [this, action]);
            this.fireEvent('actioncompleted', this, action);
        } else {
            Ext.callback(o.failure, o.scope, [this, action]);
            this.fireEvent('actionfailed', this, action);
        }
    }
    
    function ConvertFormValue(formvalue) {
        var ResultObject = new Object();
        for (var prop in formvalue) {
            ResultObject[prop] = formvalue[prop];
        }
        return ResultObject;
    }
    
    /***********************************************/
    
    
    var bd = Ext.getDom('validateCode'); 
    alert(Ext.getDom('validateCode'))     
    var bd2 = Ext.get(bd.parentNode);     
    bd2.createChild(
     [
      {tag:'span',html:''},
      {tag: 'img',id:'ImgVerifyCode', src: '/Login.mvc/GetImageCode',align:'absbottom'},
      {tag:'span',html:'   <a href=# onclick=GetImgCode()>Retry</a>'}
     ]
    );
    
    
    
    function GetImgCode()
             {
                  var randomnum = Math.random();
                  var getimagecode = document.getElementById("ImgVerifyCode");
                  getimagecode.src = "/Login.mvc/GetImageCode"+randomnum;
             }
    
    /***********************************************/
    
    Ext.onReady(Login.Init, Login, true);

    ------------------------------------------------------------------------------------
    WHY bd is null?
    Last edited by Condor; 10 May 2009 at 9:40 PM. Reason: Please post using [ CODE ] tags!

  2. #2
    Ext User
    Join Date
    Apr 2009
    Posts
    7
    Vote Rating
    0
    MechecksV is on a distinguished road

      0  

    Default


    ANYONE can help me?

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You can only access the DOM from within Ext.onReady.

    Try moving your Ext.getDom code to the Login.init() method.

Thread Participants: 1