2011-03-17 31 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 

確保您從表單中刪除全屏,因爲它不再是全屏(這個包裝面板)。