-
10 May 2012 11:45 PM #1
Answered: Uncaught TypeError: Cannot call method 'setValue' of undefined
Answered: Uncaught TypeError: Cannot call method 'setValue' of undefined
Hello
I have an email app,which uses extjs4 and springmvc.Now on the first attempt everything works fine.
i.e user can log in send mail,but after once the email is sent,if the user clicks on the send email button again,I get the following error in firebug.
at this line.Code:Uncaught TypeError: Cannot call method 'setValue' of undefined
I have used the ext.onready method for invoking the app.Also,I have the ext-all.js.Then why is the error occuring.Code:Ext.getCmp('send-to').setValue(emailAddress);
Here is the entire js code for the error.
send-to is the id of the field declared in the form.Code:var emailbtn = new Ext.Button({ text :'Send Email', scale :'medium', enableToggle:true, renderTo:'buttonMail', handler : function(){ var emailAddress = new Array(); var candidateName = new Array(); for(var i=0; i< store_company.getCount(); i++) { emailAddress.push(store_company.getAt(i).get('email')); candidateName.push(store_company.getAt(i).get('firstName')); // console.log(emailAddress); // console.log(candidateName); Ext.getCmp('send-to').setValue(emailAddress); Ext.getCmp('fName').setValue(candidateName); Ext.getCmp('send-email-window').show(); } } });
What can I do to resolve the issue??
Thanks
-
Best Answer Posted by redraid
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.window.Window-cfg-closeAction
By default window destroys after close, set values after window show:
orPHP Code:Ext.getCmp('send-email-window').show(null, function () {
Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
});
PHP Code:var win = Ext.getCmp('send-email-window');
win.on('render', function () {
Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
}, this, {single: true});
win.show();
-
11 May 2012 4:02 AM #2
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.window.Window-cfg-closeAction
By default window destroys after close, set values after window show:
orPHP Code:Ext.getCmp('send-email-window').show(null, function () {
Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
});
PHP Code:var win = Ext.getCmp('send-email-window');
win.on('render', function () {
Ext.getCmp('send-to').setValue(emailAddress);
Ext.getCmp('fName').setValue(candidateName);
}, this, {single: true});
win.show();
-
11 May 2012 4:06 AM #3
Using global ID bad - use itemId -
PHP Code:// window items
items: [
...
{itemId: 'myField', ....}
...
]
// Query item
myField = win.down('#myField');
-
11 May 2012 4:24 AM #4
Thank you redraid
I should have thought about that.
Can you just help me once again.I have a thread opened here regarding browser redirection issue.
http://www.sencha.com/forum/showthre...for-Login-Page
Please have a look and give your comments.I am able to login first attempt,but after logging out,I am not able to log in again.
Thanks


Reply With Quote