0

我正在尝试做一个用户首先需要注册的煎茶触摸应用程序。之后,会弹出一个警报,提示您已注册,当用户按下“确定”按钮时,注册表单 (register.js) 将转到登录表单 (login.js)。

这是我的 register.js:

Ext.define('demo.view.Register',{
extend:'Ext.form.Panel',
xtype:'register',

requires:[
    'Ext.form.FieldSet',
    'Ext.field.Email',
    'demo.view.Login'
],
config:{
    title:'Register',
    iconCls:'user',
    url:'doRegister.php',

    items:[
        {
            xtype:'fieldset',
            title:'Registration!!!',


            items:[
                {
                    xtype:'textfield',
                    name:'username',
                    label:'Name'
                },
                {
                    xtype:'passwordfield',
                    name:'password',
                    label:'Password'
                },
                {
                    xtype:'emailfield',
                    name:'email',
                    label:'Email'
                },
                {
                    xtype:'textfield',
                    name:'first_name',
                    label:'First Name'
                },
                {
                    xtype:'textfield',
                    name:'last_name',
                    label:'Last Name'
                }
            ]
        },
        {
            xtype:'button',
            text:'Share',
            ui:'confirm',
            handler: function() {

                // This looks up the items stack above, getting a reference to the first form it see
                var form = this.up('register');

                // Sends an AJAX request with the form data to the url specified above (contact.php).
                // The success callback is called if we get a non-error response from the server
                form.submit({
                    success: function() {
                        Ext.Msg.alert('Status', 'Resgistered Successful!', function(btn, text){
                            if (btn == 'ok'){
                                var redirect = 'login.js';
                                window.location = redirect;
                            }
                        });

                    }
                });
            }
        }
    ]
}
});

这是我的 login.js:

Ext.define('demo.view.Login',{
extend:'Ext.form.Panel',
xtype:'login',

requires:[
    'Ext.form.FieldSet',
    'Ext.field.Email'
],
config:{
    title:'Login',
    iconCls:'user',
    url:'doLogin.php',

    items:[
        {
            xtype:'fieldset',
            title:'Please Login',


            items:[
                {
                    xtype:'textfield',
                    name:'username',
                    label:'username'
                },
                {
                    xtype:'passwordfield',
                    name:'password',
                    label:'password'
                }
            ]
        },
        {
            xtype:'button',
            text:'Login',
            ui:'confirm',
            handler: function() {

                // This looks up the items stack above, getting a reference to the first form it see
                var form = this.up('share');

                // Sends an AJAX request with the form data to the url specified above (contact.php).
                // The success callback is called if we get a non-error response from the server
                form.submit({
                    method:'POST',
                    waitTitle:'Connecting',
                    waitMsg:'Sending data...',
                    success: function() {
                        Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
                            if (btn == 'ok'){
                                var redirect = 'Share.js';
                                window.location = redirect;
                            }
                        });

                    }
                });
            }
        }
    ]
}
});
4

2 回答 2

0

您可以将两个表单都放在一个带有卡片布局(布局:“卡片”)的容器中,当您想切换到登录表单时,您可以在父容器上调用 setActiveItem(1) .. 最好使用此逻辑的控制器,因此您可以引用该控制器中的所有容器/表单。

于 2012-07-07T03:35:17.473 回答
0

on alert ok button press you can create your login page to the viewport and then navigate to the login page. here is the code :

Ext.Msg.alert('Demo', "Register successfully", function(){
    Ext.Viewport.add(Ext.create('demo.view.Login'));
    Ext.Viewport.animateActiveItem(this.getLogin(),{
            type: 'slide',
            direction: 'right'
    });
 });
于 2014-07-30T06:58:43.743 回答