在sencha touch中的动画(幻灯片)转换

时间:2011-05-31 17:03:03

标签: animation sencha-touch panel

我在sencha app swich中有一个包含登录表单的面板。我认为,当表单被提交时,我想加载新内容。我想在幻灯片动画后加载新内容。我尝试使用mainPanel.setCard({type:'slide'}),但我不知道如何放置新内容。有什么想法吗?

Ext.setup({
    icon: 'icon.png',
    tabletStartupScreen: 'tablet_startup.png',
    phoneStartupScreen: 'phone_startup.png',
    glossOnIcon: false,
    onReady: function() {
        var mainPanel = new Ext.Panel({
            id:'main-panel',
            renderTo: 'content',
            html: '<h1>Please Identify:</h1><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vel neque nec mauris eleifend fringilla. Nulla sagittis placerat ullamcorper. Duis ac elit sapien. Pellentesque semper vestibulum leo id vehicula.</p>'
        });

        var form;

        Ext.regModel('User', {
            fields: [
            {
                name: 'name',
                type: 'string'
            },

            {
                name: 'password',
                type: 'password'
            },
            ]
        });

        var formBase = {
            renderTo:'main-panel',
            id: 'login-form',
            url   : 'resources/login.php',
            standardSubmit : false,
            items: [{
                xtype: 'fieldset',
                defaults: {
                    required: true,
                    labelAlign: 'left',
                    labelWidth: '40%'
                },
                items: [
                {
                    xtype: 'textfield',
                    name : 'username',
                    label: 'Usuario',
                    useClearIcon: true,
                    autoCapitalize : false
                }, {
                    xtype: 'passwordfield',
                    name : 'password',
                    label: 'Contraseña',
                    useClearIcon: false
                }
                ]
            }
            ],
            listeners : {
                submit : function(form, result){
                    console.log('success', Ext.toArray(arguments));
                },
                exception : function(form, result){
                    console.log('failure', Ext.toArray(arguments));
                }
            },
            dockedItems: [{
                xtype: 'toolbar',
                dock: 'bottom',
                items: [
                {
                    text: 'Entrar',
                    id: 'login-submit',
                    ui: 'confirm',
                    handler: function() {                        
                        form.submit({
                            method:'POST',
                            waitTitle:'Connecting',
                            waitMsg:'Sending data...',
                            success:function(response){
                                Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
                                    if (btn == 'ok'){
                                        mainPanel.setCard({
                                            type: 'slide'
                                        });
                                    }
                                });
                            },
                            failure:function(form, action){
                                Ext.Msg.alert('Status', 'Login Failed!', function(btn, text){
                                    if (btn == 'ok'){
                                        form.reset();
                                    }
                                });
                                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);
                                }
                                form.reset();
                            }
                        });
                    }
                }
                ]
            }]
        };

        Ext.apply(formBase, {
            height: 150,
            width: 300
        });

        form = new Ext.form.FormPanel(formBase);

        form.show();
    }
});

1 个答案:

答案 0 :(得分:0)

正确的代码应该是:

Ext.get('main-panel').setActiveItem(1, {type : 'slide', direction:'left'});