1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    10
    Vote Rating
    0
    wilderland is on a distinguished road

      0  

    Question understanding needed

    understanding needed


    Hello together,

    I need some clues, why this works. I adapted a example form https://extjs.com/forum/showthread.php?t=21244, because I had a problem in a FormPanel, which was embedded in a Window. I marked my question inside the code below, but maybe someone can help me.

    Thx

    Wilderland

    Code:
    NoteEditFormPanel=function(owner, config){
    	Owner = owner;
    	
    	var preConfig = {
    		url:webRoot+'notes/insertnote.json',
    		region:'center',
    		layout:'form',
    		frame:true,
    		labelAlign:'top',
    		//plain       : false,
    		url:webRoot+'notes/insertnote.json',
    		
    		items:[
    			{xtype:'textfield',fieldLabel:'Text',name:'data[n][t1]', id:'T1' },
    			{xtype:'textfield',fieldLabel:'Text1', name: 'data[n][t2]', id:'T2'}
    		]	
    		,
    		buttons: [{
    			text: 'Speichern',
    			type: 'submit',
    			handler:function(){
    				var f = this.ownerCt.getForm();
    				var v = f.getValues(true);
    				this.ownerCt.info(v);
    				f.submit({
    				    url:webRoot+'notes/insertnote.json',
    				    success: function (form, action) {
    				        Ext.MessageBox.alert('Message', 'Saved OK ');
    				    	var f1 = Ext.getCmp(Owner.id); //Why does it work? Owner.id should be a "class variable" of NoteEditFormPanel, why does the function get access to it?
    				    	if(f1){
    				    		f1.close();
    				    	}
    				    },
    				    failure:function(form, action) {
    				        Ext.MessageBox.alert('Message', 'Save failed');
    				    }
    				});
    			}
    		},{
    			text: 'Abbrechen',
    			handler:function(){
    				
    			}
    		}]
    	};
    	
    	NoteEditFormPanel.superclass.constructor.call(this, preConfig);
    	
    	
    };
    
    ////////////////////////////////////////////////////////////////
    
    Ext.extend(NoteEditFormPanel, Ext.FormPanel, {
    	info: function(data){
    		alert('info:'+data);
    	}
    	
    });

  2. #2
    Ext User
    Join Date
    Feb 2008
    Posts
    200
    Vote Rating
    2
    tomcheng76 is on a distinguished road

      0  

    Default


    It is about scope issue.
    In the function that you call getCmp, there isn't any 'var Owner' , so it looks the variable from the outside world (world that outside the function bracket).
    see from the scope tutorial here

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar