PDA

View Full Version : a is undefined



mayur_satasiya
19 Jun 2012, 10:46 PM
Hi, I am using ExtJS 4 and i am adding component dynamically to panel and working fine. But when i remove component from panel and submit form getting error a is undefined while using ext-all.js and o is undefined while using ext-debug.js
So how to solve this error

CODE:

Ext.onReady(function(){ Ext.create('Ext.form.Panel', {
requires: ['DYNFM.controller.DynamicForm'],
title: 'File Uploader',
width: 400,
id : 'panel1',
bodyPadding: 10,
frame: true,
renderTo: 'fi-form',
items: [{
xtype: 'filefield',
name: 'file',
id: 'items',
fieldLabel: 'File',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select a File...',
}],
buttons: [{
text: 'Upload',
handler: function() {
alert('in handler');
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'upload.action',
waitMsg: 'Uploading your file...',
success: function(action, response) {
Ext.Msg.alert('Success', 'Your file has been uploaded.');
},
failure:function(form, action){
if(action.failureType == 'server'){
// obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Failure!', 'File Upload Failed');
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);
}
formPanel.getForm().reset();
}
});
}
}
},
{
text: 'Add',
handler: function() {
//click: this.clickAdd
/*Ext.getCmp('panel1').remove(fi);
Ext.getCmp('panel1').doLayout();*/
this.addRow();
},
addRow : function () {
this.count = this.count + 1,
Ext.getCmp('panel1').add([{
xtype: 'fieldcontainer',
id: 'edu_items'+this.count,
height: 22,
layout: 'hbox',
items: [{
xtype :'filefield',
name: 'file'+ this.count,
//id :'file'+ this.count,
fieldLabel: 'File',//+this.count,
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select a File...',
flex: 1
},{
xtype: 'button',
text:'Delete',
id : this.count,
handler: function() {
//click: this.clickAdd
Ext.getCmp('panel1').remove(Ext.getCmp('edu_items'+this.id));
Ext.getCmp('panel1').doLayout();
// alert(this.id);
// click :this.delRow();

}
}]
}]);
},
count: 0,
}]
});


});

tobiu
20 Jun 2012, 4:12 AM
use the debugging tools (stack trace) to see what is happening.
for developent i recommend never to use the ext-all* files.

take a look at:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.container.AbstractContainer-method-remove

the method has a second parameter autoDestroy which is set to true by default. If the formpanel gets destroyed, a submit won't work for obvious reasons.

mayur_satasiya
20 Jun 2012, 4:19 AM
use the debugging tools (stack trace) to see what is happening.
for developent i recommend never to use the ext-all* files.

take a look at:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.container.AbstractContainer-method-remove

the method has a second parameter autoDestroy which is set to true by default. If the formpanel gets destroyed, a submit won't work for obvious reasons.

Thanks for replay 36373
But what is happening with this form is while i add some component and without upload i am removing that added component from panel then default file upload field also not working that gives an error a is not defined
So what to do with code given above, Please help me
Thanks in advance

scottmartin
20 Jun 2012, 12:56 PM
Try removing all 'id' in your code .. it could be some toes are getting stepped on.
(use itemId)

Scott.

mayur_satasiya
20 Jun 2012, 9:13 PM
Try removing all 'id' in your code .. it could be some toes are getting stepped on.
(use itemId)

Scott.

Thanks Scott
But in my case i have changed id to itemId and it's not working for me.You have any other solution.
it throws Ext.getCmp("panel1") is undefined error
thanks in advance.

scottmartin
21 Jun 2012, 6:16 AM
Have you debugged your code as mentioned by Tobias? What debugger are you using?

Scott.

mayur_satasiya
21 Jun 2012, 8:35 PM
Have you debugged your code as mentioned by Tobias? What debugger are you using?

Scott.

HI Scoot I am using firebug in mozilafirefox, and i don't know about debugger about you are talking. Please tell me in brief about that debugger and how to debug. Thanks in advance

scottmartin
22 Jun 2012, 5:17 AM
Firebug can be used. You can set breakpoints in your script and place watches on your objects and see what is happening as it executes.

Chrome has a built in DeveloperTools that can also be used.

Scott.