2014-09-20 40 views
1

我目前正在使用ExtJS。我有一個textText有一個空文本設置爲配置。 「emptyText:'請輸入'」清除焦點上的空文本

當我點擊它時,它不會消失。只有當我輸入某些東西時,它纔會發生。有什麼辦法可以做到這一點?

回答

0

它應該的xtype工作:「文本框」。你能提供更多關於你的嘗試的細節嗎? 我沒有得到任何問題。 以下是示例代碼。

var form = new Ext.form.FormPanel({ 
    items: [{ 
     name: 'Test', 
     xtype:'textfield', 
     emptyText:'Empty Text', 
    }] 
}); 
1

我真的不喜歡這個解決方案,但我想出這個(viewable here):

Ext.application({ 
    name : 'Fiddle', 

    launch : function() { 
    Ext.create('Ext.form.Panel', { 
     title: 'Contact Info', 
     width: 300, 
     bodyPadding: 10, 
     renderTo: Ext.getBody(), 
     items: [{ 
     xtype: 'textfield', 
     name: 'name', 
     fieldLabel: 'Name', 
     allowBlank: false, // requires a non-empty value, 
     emptyText: 'blah', 
     originalEmptyText: 'blah', 
     listeners: { 
      focus: function() { 
      this.emptyText = ' '; // if you set it to empty string, it doesn't work 
      this.applyEmptyText(); 
      }, 
      blur: function() { 
      this.emptyText = this.originalEmptyText; 
      this.applyEmptyText(); 
      } 
     } 
     }] 
    }); 
    } 
});