Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you are very close to doing this already - just call your <strong>newRulesField</strong> function from your <strong>handleRuleKeypress</strong> function. something like this:</p> <pre><code>function handleNewRuleSetClick(nodes) { var nameField = new Ext.form.TextField({ fieldLabel: 'Name', name: 'ruleSetName', anchor: '100%', allowBlank: false, grow: false }); var descField = new Ext.form.TextField({ fieldLabel: 'Description', name: 'ruleSetDescription', anchor: '100%', allowBlank: false, grow: false }); var form = new Ext.FormPanel({ labelWidth: 75, defaultType: 'textfield', bodyStyle: 'padding:30px', id: 'newRuleSetPanel', name: 'newRuleSetPanel', title: 'New Rule Set', buttons: [{ text: 'Save', id: 'saveBtn', hidden: false, handler: function() { form.getForm().submit({ url: 'server/new-rule-set', waitMsg: 'Saving...', success: function(f, a) { Ext.Msg.alert('Success', 'It worked'); }, failure: function(f, a) { Ext.Msg.alert('Warning', 'Error'); } }); } }, { text: 'Cancel', id: 'cancelBtn', hidden: false }] }); function handleRuleKeypress(a, b) { form.add(newRulesField('rules' + Ext.id())); } function newRulesField(name) { var rulesField = new Ext.form.TextArea({ fieldLabel: 'Rules', anchor: '100%', name: name, allowBlank: false, grow: false, enableKeyEvents: true, listeners: { keypress: handleRuleKeypress } }); return rulesField; } form.add(nameField); form.add(descField); form.add(newRulesField('rules1')); this.add(form); this.doLayout(); } </code></pre> <p>you will want additional logic for checking if you have already added the new text area (or you will get a new one for each key press), perhaps removing the additional text area if the latest rule is emptied later on, and fixing the textarea id's a little prettier (all this is your <strong>handleRuleKeypress</strong> func).</p> <p>My general thoughts on your application design is to keep the FormPanel as a class member somewhere instead of a private function member, this will make it easier to access whenever it comes to modifying it after creation - stacking functions like this is not very pretty nor readable.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload