You need to sign in to do that
Don't have an account?
Stefan van der Knaap
lightning error during init
Hi,
I'm stuck with a Lightning component that doesn't render. I get a strange error immediately: This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined].
I'm stuck now for a long time and can't figure out what is wrong with the code. Here you can see my code:
Component:
I really somebody can help me!
Thanks in advance, Stefan
I'm stuck with a Lightning component that doesn't render. I get a strange error immediately: This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined].
I'm stuck now for a long time and can't figure out what is wrong with the code. Here you can see my code:
Component:
<aura:component controller="CaseActivityTrackerCtrl" implements="flexipage:availableForAllPageTypes"> <aura:attribute name="recordId" type="String" default='500b000000cOxah' /> <aura:attribute name="case" type="Case" /> <aura:attribute name="tasks" type="Task[]"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <c:CaseActivityTrackerHeader /> <aura:iteration items="{!v.tasks}" var="task"> <c:CaseActivityTrackerTimeline task="{!task}"/> </aura:iteration> <aura:iteration items="{!v.tasks}" var="task"> <h3>{!v.task.Subject}</h3> </aura:iteration> <h3>{!v.case.Subject}</h3> <h3>{!v.recordId}</h3> </aura:component>
({ doInit: function(component, event, helper) { //helper.getCase(component, event); //helper.getTasks(component, event); // Set the attribute value. // You could also fire an event here instead. component.set("v.recordId", "controller init magic!"); } })App
<aura:application extends="force:slds"> <c:CaseActivityTracker /> <!-- <c:camping /> --> </aura:application>
I really somebody can help me!
Thanks in advance, Stefan
All Answers
Hey,
This is very general error salesforce throw. I got the same error for different reason. Best way to debug is pressing F12 and do console debuging and you will find thee actual error.
hope this additional information helps you @stefan
Try disabling each one at a time and refresh the Salesforce page.
In my case, the Chrome Extension causing troubles was "React-Sight".
<aura:component controller="OpportunityController">
<aura:attribute name="opportunities" type="Opportunity[]"/>
<ui:button label="Get Opportunities" press="{!c.getOpportunities}"/>
<aura:iteration var="opportunity" items="{!v.opportunities}">
<p>{!v.opportunity.Name}:{!v.opportunity.CloseDate}</p>
</aura:iteration>
</aura:component>
Controller:
({
getOpps: function(cmp){
var action = cmp.get("c.getOpportunities");
/*action.setParams({ opportunities : cmp.get("v.opportunities") });*/
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
cmp.set("v.opportunities", response.getReturnValue());
}
/* else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}*/
});
$A.enqueueAction(action);
}
})
Appex class:
public class OpportunityController {
@auraenabled
public static list<opportunity> getopper(){
list<opportunity> op=[select id,name,CloseDate from opportunity ];
system.debug(op);
return op;
}
@AuraEnabled
public static Opportunity getOpportunity(Id id) {
Opportunity opportunity = [
SELECT Id, Account.Name, Name, CloseDate,
Owner.Name, Amount, Description, StageName
FROM Opportunity
WHERE Id = :id
];
// Perform isAccessible() check here
return opportunity;
}
}