You need to sign in to do that
Don't have an account?
Rony57
Cannot read property 'push' of undefined
Hi all,
While working on my lightning components, one error is coming . Is there anybody who can help me out ?
Error- Cannot read property 'push' of undefined.
here is the sample of Helper.js
({
createBAccount : function(component,BAccount) {
this.upsertExpense(component, expense, function(a) {
var BAccount = component.get("v.BAccount");
BAccount.push(a.getReturnValue());
component.set("v.BAccount", BAccount);
this.updateTotal(component);
});
},
upsertExpense : function(component, BAccount, callback) {
var action = component.get("c.saveBAccount");
action.setParams({
"BAccount": BAccount
});
if (callback) {
action.setCallback(this, callback);
}
$A.enqueueAction(action);
},
})
The bold one is getting an error over here .
While working on my lightning components, one error is coming . Is there anybody who can help me out ?
Error- Cannot read property 'push' of undefined.
here is the sample of Helper.js
({
createBAccount : function(component,BAccount) {
this.upsertExpense(component, expense, function(a) {
var BAccount = component.get("v.BAccount");
BAccount.push(a.getReturnValue());
component.set("v.BAccount", BAccount);
this.updateTotal(component);
});
},
upsertExpense : function(component, BAccount, callback) {
var action = component.get("c.saveBAccount");
action.setParams({
"BAccount": BAccount
});
if (callback) {
action.setCallback(this, callback);
}
$A.enqueueAction(action);
},
})
The bold one is getting an error over here .
I don't know much about the lightning component, but from the error and code what I can tell is that "BAccount" is undefined in your CreateBAccount function. check from where the function is being called and see if that's passing the correct value.
Regards,
Vivek Patel.
All Answers
I don't know much about the lightning component, but from the error and code what I can tell is that "BAccount" is undefined in your CreateBAccount function. check from where the function is being called and see if that's passing the correct value.
Regards,
Vivek Patel.
Thanx alot buddy, Yes error is due to passing an incorrect value in the controller section.Thanx for your response.
Can you please mark this as solved, if your issue is resolved.
Regards,
Vivek Patel