1

我的控制器

Ext.define('MyApp.controller.login', {
    extend: 'Ext.app.Controller',
    requires: ['MyApp.view.login', 'Ext.field.Input', 'Ext.Ajax'],
    config: {
        refs: {
            loginButton : ' login #logInButton',
            loginform   : 'login #loginform'
        },
        control: {
            loginButton:{
                tap: 'loginButton'
            }
        }
    },
    //functions
    loginButton: function(){
        Ext.Msg.alert('Logged In');

        Ext.Ajax.request({
            url: getLogonUrl(),
            method: 'POST',
            params: {
                username: Ext.getCmp('username').getValue(),
                password: Ext.getCmp('password').getValue(),
            },
            success: function (response) {
                Ext.Msg.alert('Logged In');

                var result = Ext.JSON.decode(response.responseText);
                console.log(resultResponse.Texts);
                if (result.success === "true") 
                    Ext.Msg.alert('Logged In');
                else 
                    Ext.Msg.alert('Not Logged In');
            },
        });
    }
});

我的登录在视图中

Ext.define('MyApp.view.login', {
    extend: 'Ext.form.Panel',
    alias: "widget.loginview",
    xtype: 'login',
    requires: [
        'Ext.form.FieldSet','Ext.field.Text', 'Ext.Button',
        'Ext.field.Password','Ext.field.Hidden', 'Ext.Img'  
    ],
    config:{
        id: 'loginform',
        iconCls: 'user',
        title: 'Login',
        styleHtmlCls: true,
        styleHtmlContent: true,
        scrollable: null,
        items: [
            {       
                xtype: 'image',
                src:'app/view/img/airitlogo.png',
                height: 200,
                style:{ top: '100px'},
            },   
            {
                xtype: 'fieldset',
                width: 1500,
                height: 200,
                style: ' margin: 150px 0px 0px 200px', // backgroundColor: ' #015486'}
                cls: 'login',
                title: '<div id="title">PROPworks - Meter Sign In</div>',
                items: [
                    {
                        xtype: 'label',
                        html: 'Activation failed',
                        itemId: 'failLogin',
                        hidden: true,
                        hideAnimation: 'fadeOut',
                        showAnimation: 'fadeIn',
                        style: 'background: yellow; margin: 5px, 0px',
                    },
                    {
                        xtype: 'textfield',
                        placeHolder: 'Username',
                        Id: 'username',
                        name : 'usernameTextField',
                        style: 'height: 60px',  
                    },
                    {
                        xtype: 'passwordfield',
                        placeHolder: 'Password',
                        Id: 'password',
                        name : 'passwordTextField',
                        style: 'height: 60px',
                    }
                ]//second item list
            },
            {
                xtype:  'button',
                itemId: 'logInButton',
                text:   'Log In',
                ui:     'confirm',
                cls: 'button',
                width: 1500,
                style: ' margin: 15px 0px 0px 200px; height: 70px',
            },          
        ]//first item list
    }
});

一个Ext.msg.alert(),一旦超过ajax.request就不起作用,我的 url 是一个从我在我的 html 文件头部导入的文件中调用的函数

<!DOCTYPE HTML>
<html manifest="" lang="en-US">
<head>
    <meta charset="UTF-8">

    <script type="text/javascript" src="js/pwmain-ui.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"> </script>
    <script type="text/javascript" src="js/jquery-ui.js"> </script>
    <script type="text/javascript" src="js/jsonselect.min.js"> </script>    
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/jquery.atmosphere.js"> </script>
    <title>MyApp</title>
4

1 回答 1

2

您的代码中有很多不必要,的内容会破坏 sencha。

也许我错了,但你不应该,在结束}]括号之前放。

我试图清理这些。这些很容易打破煎茶。至少我对这类事情有很多问题。

Ext.define('MyApp.controller.login', {
    extend: 'Ext.app.Controller',
    requires: ['MyApp.view.login', 'Ext.field.Input', 'Ext.Ajax'],
    config: {
        refs: {
            loginButton : ' login #logInButton',
            loginform   : 'login #loginform'
        },
        control: {
            loginButton:{
                tap: 'loginButton'
            }
        }
    },
    //functions
    loginButton: function(){
        Ext.Msg.alert('Logged In');

        Ext.Ajax.request({
            url: getLogonUrl(),
            method: 'POST',
            params: {
                username: Ext.getCmp('username').getValue(),
                password: Ext.getCmp('password').getValue()
            },
            success: function (response) {
                Ext.Msg.alert('Logged In');

                var result = Ext.JSON.decode(response.responseText);
                console.log(resultResponse.Texts);
                if (result.success === "true") 
                    Ext.Msg.alert('Logged In');
                else 
                    Ext.Msg.alert('Not Logged In');
            }
        });
    }
});

登录视图:

Ext.define('MyApp.view.login', {
    extend: 'Ext.form.Panel',
    alias: "widget.loginview",
    xtype: 'login',
    requires: [
        'Ext.form.FieldSet','Ext.field.Text', 'Ext.Button',
        'Ext.field.Password','Ext.field.Hidden', 'Ext.Img'  
    ],
    config:{
        id: 'loginform',
        iconCls: 'user',
        title: 'Login',
        styleHtmlCls: true,
        styleHtmlContent: true,
        scrollable: null,
        items: [
            {       
                xtype: 'image',
                src:'app/view/img/airitlogo.png',
                height: 200,
                style:{ top: '100px'}
            },   
            {
                xtype: 'fieldset',
                width: 1500,
                height: 200,
                style: ' margin: 150px 0px 0px 200px', // backgroundColor: ' #015486'}
                cls: 'login',
                title: '<div id="title">PROPworks - Meter Sign In</div>',
                items: [
                    {
                        xtype: 'label',
                        html: 'Activation failed',
                        itemId: 'failLogin',
                        hidden: true,
                        hideAnimation: 'fadeOut',
                        showAnimation: 'fadeIn',
                        style: 'background: yellow; margin: 5px, 0px'
                    },
                    {
                        xtype: 'textfield',
                        placeHolder: 'Username',
                        Id: 'username',
                        name : 'usernameTextField',
                        style: 'height: 60px'
                    },
                    {
                        xtype: 'passwordfield',
                        placeHolder: 'Password',
                        Id: 'password',
                        name : 'passwordTextField',
                        style: 'height: 60px'
                    }
                ]//second item list
            },
            {
                xtype:  'button',
                itemId: 'logInButton',
                text:   'Log In',
                ui:     'confirm',
                cls: 'button',
                width: 1500,
                style: 'margin: 15px 0px 0px 200px; height: 70px'
            }          
        ]//first item list
    }
});
于 2013-10-31T18:10:59.400 回答