2012-10-31 64 views
1

我在我的應用程序中有很多TextField,都有相同的問題: 按下右側的清除圖標後,此文本框的焦點丟失。覆蓋系統事件:文本框清除

This solution的作品,但效率不高,因爲那時我不得不這樣做對每一個文本框:

   { 
        xtype: 'textfield', 
        label: 'Name', 
        onClearIconTap: function() { 
             this.setValue(''); 
             console.log('onClearTap'); 
            } 
       } 

我遇到this page,重寫事件,但它不工作。這將是一個首選的解決方案:

任何幫助嗎?

回答

0

一個更美好的解決方案(帶觸摸2.3.0工程):

Ext.define('MyApp.override.field.Text', { 
    override: 'Ext.field.Text', 
    // @private 
    doClearIconTap: function(me, e) { 
     me.setValue(this.originalValue); 

     me.focus(); 

     //sync with the input 
     me.getValue(); 
    } 
}); 
+0

是true,並且可能會在地圖覆蓋中爲此創建額外的類文件。 – andy

3

下面是如何重寫功能,app.js推出功能爲內煎茶觸摸2:

Ext.field.Text.override({ 
     onClearIconTap: function() { 
      this.setValue(''); 
      this.focus(); 
      console.log('global onClearTap'); 
     } 
    }); 

http://jsfiddle.net/QYJpc/46/