0

简而言之,我有一个登录面板,当 onClick 事件为 true 时会显示该面板,但出现错误Cannot read property 'dom' of null。当我第二次单击时 - 显示面板,但未显示其中的某些元素。当我第三次单击时,其他元素显示最后一个错误“无法调用未定义的方法'bringToFront'”。

Ext.onReady(function() {

    Ext.QuickTips.init();
    Ext.ns('Site.login');

    var globalKeyMap = new Ext.KeyMap(document);
    globalKeyMap.accessKey = function(key, handler, scope) {
        var h = function(n, e) {
            e.preventDefault();
            handler.call(scope || this, n, e);
        };
        this.on(key, h, scope);
    };

    var trackEnter = function(tf, e) {
        if (e.keyCode == 13) {
            e.stopPropagation();
            doLogin();
        }
    }

    var doLogin = function() {
        var f = loginPanel.getForm();
        if (f.isValid()) {
            f.doAction(new Hypo.form.Action.DwrSubmit(f, {
                waitMsg: 'Authentication is in progress',
                invoker: function(form, cb) {
                    Login.login(form.getValues(), cb);
                },
                success: function(fp, o) {
                    loginForm.hide();
                    Ext.getBody().addClass("x-body-masked");
                    var w = loginForm;
                    w.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
                    w.mask.show();
                    if(o.result.data[0].authorities[0].authority=='ROLE_SUPERVISOR')
                    {
                        setTimeout('document.location = "AdminUsers.jsp"');
                    }
                    else if(o.result.data[0].authorities[0].authority=='ROLE_ADMIN')
                    {
                        setTimeout('document.location = "AdminUsers.jsp"');
                    }
                    else
                    {
                        setTimeout('document.location = "List.jsp"');
                    }
                }
            }));
        }
    }

    var loginPanel = new Ext.FormPanel({
        id: 'loginPanel',
        labelWidth: 75, // label settings here cascade unless overridden
        frame: false,
        border: false,
        bodyStyle:'padding:5px 5px 0',
        width: 350,
        defaults: {
            width: 230
        },
        defaultType: 'textfield',
        autoHeight: true,
        items: [{
            id: 'idxLogin',
            fieldLabel: 'Login',
            name: 'login',
            allowBlank: false,
            enableKeyEvents: true,
            maxLength: 50,
            listeners: {
                'keypress': trackEnter
            }
        }, new Ext.form.TextField({
            fieldLabel: 'Password',
            name: 'password',
            inputType: 'password',
            enableKeyEvents: true,
            maxLength: 50,
            listeners: {
                'keypress': trackEnter
            }
        })
        ]
    });

    var loginForm = new Ext.Window({
        layout      : 'fit',
        width       : 350,
        closable    : false,
        modal: true,
        plain       : true,
        title: 'User Authentication',
        items: loginPanel,
        autoHeight: true,
        buttons: [{
            text: 'OK',
            handler: doLogin
        },{
            text: 'Cancel',
            handler: function() {
                loginForm.hide();
            }
        }],
        listeners: {
            'activate': function() {
                setTimeout(function() {
                    Ext.getCmp("idxLogin").focus();
                }, 100);
            }
        }
    });
    Site.login.window = loginForm;

    });

<a href="javascript://" onclick="Site.login.window.show();return false">Login</a>

我尝试添加 renderTo:'someDiv' 并将 ID 为“someDiv”的 div 添加到正文。但我收到了同样的错误信息。

请帮忙。

4

0 回答 0