1. #1
    Ext User Davi Baldin's Avatar
    Join Date
    Jul 2007
    Location
    Campinas, S
    Posts
    25
    Vote Rating
    0
    Davi Baldin is on a distinguished road

      0  

    Thumbs up [TIP] Destroy form every time !

    [TIP] Destroy form every time !


    In specific context, i need to reder dynamic form with diferents fields. So with this code, i recreate without problem the form every time...

    this code worksforme:

    Code:
    createForm : function(paramType,paramList) {
    			if(form) {
    				Ext.get('paramForm').remove();
    				form = null;
    			}
    			
    			form = new Ext.form.Form({id: 'paramForm'});
    and the object

    Code:
    ParametersEditorDialog = function(){
    	
    	var form;
    	var dialog;
    	
    	return {
    		createForm : function(paramType,paramList) {
    			if(form) {
    				Ext.get('paramForm').remove();
    				form = null;
    			}
    			
    			form = new Ext.form.Form({id: 'paramForm'});
    			
    			form.add(
            		new Ext.form.TextField({
                			fieldLabel: paramType,
                			name: 'first',
                			width:175,
                			allowBlank:false,
    				id: 'f1'
            		}));
    			
    			//Render
    			form.render('parameters-dialog-form');
    		}
    		//... cuted here
    	};
    //Function end
    }();
    thats is !!!

    Davi
    Last edited by Davi Baldin; 21 Jul 2007 at 4:18 PM. Reason: grammar error

  2. #2
    jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Yeah, once a form is rendered you do have to destroy it other wise you can't add things to it dynamically ,etc.

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    210
    Vote Rating
    1
    KRavEN is on a distinguished road

      0  

    Default


    To avoid giving the form an id, which I don't like doing:

    PHP Code:
          if (form) {
            
    form.el.remove();
            
    form null;
          }; 

Thread Participants: 2