2011-03-17 72 views
3

只需潜入SenchaTouch看起来很有前途。SenchaTouch的简单登录表格

我建立我的第一个应用程序,一个简单的登录表单检查源http://pastebin.com/8Zddr9cj

我正在寻找一个方式做以下的事情:

  • 显示“好”的错误消息时登录名/密码错误。可以用红色代替'请输入你的凭证';我不知道如何访问这个属性。

  • 如果登录成功,关闭表单并加载应用程序(可能是另一个js文件)。

相当简单,但我是一个新手到这一点,

回答

1

1)字段集有一个名为setInstructions,你可以打电话到更新的说明方法。因此,您可以在字段集中指定id配置,然后在想要更新说明时稍后使用该配置。

... 
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: '[email protected]', 
      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)这里就是一个简单的演示:

//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 

确保您从表单中删除全屏,因为它不再是全屏(这个包装面板)。