Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi can you please help me in switch a screen. I have two screen 1 and b , but when I click the login button it goes to b screen but i am not able to do that

This is app.js
JavaScript
Ext.Loader.setConfig({
    enabled: true
});

Ext.application({
    views: [
        'a',
        'b'
            ],
            controller:['AppController'],
    name: 'MyApp',

    launch: function() {

        Ext.create('MyApp.view.a', {fullscreen: true});
    }

});


this is first view a.js

Ext.define('MyApp.view.a', {
    extend: 'Ext.form.Panel',

    config: {
        items: [
            {
                xtype: 'textfield',
                border: 10,
                height: 37,
                label: 'User Name',
                labelWidth: '40%',
                name: 'user-name',
                maxLength: 20
            },
            {
                xtype: 'passwordfield',
                height: 28,
                margin: 10,
                label: 'Password',
                labelWidth: '40%',
                name: 'password'
            },
            {
                xtype: 'button',
                centered: true,
                height: 40,
                ui: 'action-round',
                width: 120,
                text: 'Login',
                text: 'Login',
                listeners: {
        tap: function() {
            //alert("You tapped me");
        }
    }


            },
            {
                xtype: 'button',
                bottom: 20,
                centered: true,
                height: 42,
                left: 120,
                margin: 10,
                padding: '',
                ui: 'action-round',
                text: 'Register'
            }
        ]
    }

});

second view b.js
Ext.define('MyApp.view.b', {
    extend: 'Ext.form.Panel',

    config: {
        items: [

            {
                xtype: 'passwordfield',
                height: 28,
                margin: 10,
                label: 'Password',
                labelWidth: '40%',
                name: 'password'
            },
            {
                xtype: 'button',
                centered: true,
                height: 40,
                ui: 'action-round',
                width: 120,
                text: 'Login'
            },
            {
                xtype: 'button',
                bottom: 20,
                centered: true,
                height: 42,
                left: 120,
                margin: 10,
                padding: '',
                ui: 'action-round',
                text: 'Register'
            }
        ]
    }

});

what should i change in controller so that it navigate to second screeb on clicking the button login

Ext.define('MyApp.controller.AppController', {
    extend: 'Ext.app.Controller',
    config: {
        refs: {
            Loginform: 'a',
            Registrationform: 'b'
        },

        control: {
            "Loginform": {
                tap: 'onButtonTap'
            }
        }
    },

    onButtonTap: function(button, e, options) {
        console.log("Hi");
       // this.getMain().setActiveItem(1);

    }

});

[Edit]Code block added[/Edit]
Posted
Updated 16-Jan-13 6:47am
v2
Comments
Sergey Alexandrovich Kryukov 16-Jan-13 14:25pm    
Is it JavaScript? Then add a tag, using "Improve question" above.
And, if this is JavaScript, what could you possibly mean by "screen"?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900