2012-11-08 74 views
-1

我在頁面上共有六個文本框。默認情況下它只會顯示兩個文本框。它還有一個「添加文本」按鈕。當我點擊按鈕時,它會一次添加一個文本框。那麼,我如何在extjs中實現這個功能。在按鈕單擊事件頁面中添加文本框

請幫助..

回答

1
Ext.require('*'); 
Ext.onReady(function() { 

    var i = 0; 

    Ext.create('Ext.button.Button', { 
     renderTo: document.body, 
     text: 'Add', 
     handler: function(){ 
      ++i; 
      form.add({ 
       xtype: 'textfield', 
       fieldLabel: 'Field ' + i 
      }); 
     } 
    }) 

    var form = new Ext.form.Panel({ 
     bodyPadding: 5, 
     renderTo: document.body, 
     width: 300, 
     items: [] 
    }); 

}); 
+0

感謝埃文!它的工作正常 –

相關問題