2014-09-20 42 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(); 
      } 
     } 
     }] 
    }); 
    } 
});