EXT未定义登录示例

时间:2014-12-17 16:56:27

标签: extjs

我正在尝试使用Extjs 3.4.0实现简单的登录代码,给出了所有包含文件的绝对路径,仍然面临Ext未定义的错误。我正在使用firebug进行调试。

<html>
<head>
<link rel="stylesheet" type="text/css" href="E:/SICSR/ext-3.4.0/ext-3.4.0/resources/css/ext-all.css">   
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/ext-all.js"></script>
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/adapter/ext/ext-base.js"></script>

<SCRIPT TYPE="text/javascript">

Ext.onReady(function(){
Ext.QuickTips.init();

// Create a variable to hold our EXT Form Panel. 
// Assign various config options as seen.    
var login = new Ext.FormPanel({ 
    labelWidth:80,
    url:'login.asp', 
    frame:true, 
    title:'Please Login', 
    defaultType:'textfield',
monitorValid:true,
// Specific attributes for the text fields for username / password. 
// The "name" attribute defines the name of variables sent to the server.
    items:[{ 
            fieldLabel:'Username', 
            name:'loginUsername', 
            allowBlank:false 
        },{ 
            fieldLabel:'Password', 
            name:'loginPassword', 
            inputType:'password', 
            allowBlank:false 
        }],

// All the magic happens after the user clicks the button     
    buttons:[{ 
            text:'Login',
            formBind: true,  
            // Function that fires when user clicks the button 
            handler:function(){ 
                login.getForm().submit({ 
                    method:'POST', 
                    waitTitle:'Connecting', 
                    waitMsg:'Sending data...',

        // Functions that fire (success or failure) when the server responds. 
        // The one that executes is determined by the 
        // response that comes from login.asp as seen below. The server would 
        // actually respond with valid JSON, 
        // something like: response.write "{ success: true}" or 
        // response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}" 
        // depending on the logic contained within your server script.
        // If a success occurs, the user is notified with an alert messagebox, 
        // and when they click "OK", they are redirected to whatever page
        // you define as redirect. 

                    success:function(){ 
                        Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
               if (btn == 'ok'){
                            var redirect = 'test.asp'; 
                            window.location = redirect;
                               }
                });
                    },

        // Failure function, see comment above re: success and failure. 
        // You can see here, if login fails, it throws a messagebox
        // at the user telling him / her as much.  

                    failure:function(form, action){ 
                        if(action.failureType == 'server'){ 
                            obj = Ext.util.JSON.decode(action.response.responseText); 
                            Ext.Msg.alert('Login Failed!', obj.errors.reason); 
                        }else{ 
                            Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText); 
                        } 
                        login.getForm().reset(); 
                    } 
                }); 
            } 
        }] 
});


// This just creates a window to wrap the login form. 
// The login object is passed to the items collection.       
var win = new Ext.Window({
    layout:'fit',
    width:300,
    height:150,
    closable: false,
    resizable: false,
    plain: true,
    border: false,
    items: [login]
});
win.show();
});
</SCRIPT>
</head>
<body>




</body>
</html>

提前感谢!

Yuta Lolap。

1 个答案:

答案 0 :(得分:0)

首先包含适配器的脚本标签:

<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="E:/SICSR/ext-3.4.0/ext-3.4.0/ext-all.js"></script>

请参阅示例:http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/array-grid.html并查看 HTML 源(不是array-grid.js的源代码),特别是第38-43行:

<!-- ** Javascript ** -->
<!-- ExtJS library: base/adapter -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>

<!-- ExtJS library: all widgets -->
<script type="text/javascript" src="../../ext-all.js"></script>