Simple login form with SenchaTouch

时光总嘲笑我的痴心妄想 提交于 2019-12-21 05:41:17

问题


Just diving into SenchaTouch which seems very promising.

I'm building my first application, a simple login form check source http://pastebin.com/8Zddr9cj

I'm looking for a way to do the following things :

  • Display 'nice' error message when the login/password is wrong. Can be in red to replace the 'Please enter your credentials); i don't know how to access this property.

  • If login success, close the form and load the application (probably another js file).

Quite simple, but i'm a newbie to this,


回答1:


1) Fieldset has a method called setInstructions which you can call to update the instructions. So, you could specify an id configuration in your field set, then use that later on when you want to update the instructions.

...
items: [
    {
        xtype: 'fieldset',
        id: 'fieldset',
        title: 'Login',
        instructions: 'Please enter your credentials',
        defaults: {
            required: true,
            labelAlign: 'left',
            labelWidth: '40%'
        },
        items: [
        {
            xtype: 'emailfield',
            name : 'email',
            label: 'Email',
            placeHolder: 'your@email.com',
            useClearIcon: true
        }, {
            xtype: 'passwordfield',
            name : 'password',
            label: 'Password',
            useClearIcon: false
        }]
    }
],
...

//wherever you want to update the instructions
var fieldset = Ext.getCmp('fieldset');
fieldset.setInstructions('My new instructions!');

2) Here is a simple demo of this:

//create a panel, which is full screen, and will contain your form, and another item
//which you want to show at some point
var wrapper = new Ext.Panel({
    fullscreen: true,
    layout: 'card',

    //my two items
    items: [
        form,
        {
            xtype: 'panel',
            html: 'my second panel, which is not visible on render.'
        }
    ]
});

//change the active card/item, when you need to
wrapper.setActiveItem(1); //starts at 0

Make sure you remove fullscreen from your form, as it is no longer fullscreen (this wrapper panel is).



来源:https://stackoverflow.com/questions/5339831/simple-login-form-with-senchatouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!