You need to sign in to do that
Don't have an account?
Dora Babu KOTTHRU 7
The campingList JavaScript controller doesn't have a 'doInit' function or doesn't call the Apex controller to get items from the database.
Though my campingList JavaScript controller have doInit , I am getting 'doInit' function or doesn't call the Apex controller to get items from the database. Not sure what went wrong. Please help me.
({
doInit: function(component, event, helper) {
// Create the action
var action = component.get("c.getItems");
// Add callback behavior for when response is received
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
//component.set("v.item", response.getReturnValue());
helper.controllerHelper(component,response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
// Send action off to be executed
$A.enqueueAction(action);
},
clickCreateCamping: function(component, event, helper) {
if(helper.validateCampingForm(component)){
var newCamping = component.get("v.newItem");
helper.createItem(component, newCamping);
}
}
})
({
doInit: function(component, event, helper) {
// Create the action
var action = component.get("c.getItems");
// Add callback behavior for when response is received
action.setCallback(this, function(response) {
var state = response.getState();
if (component.isValid() && state === "SUCCESS") {
//component.set("v.item", response.getReturnValue());
helper.controllerHelper(component,response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
// Send action off to be executed
$A.enqueueAction(action);
},
clickCreateCamping: function(component, event, helper) {
if(helper.validateCampingForm(component)){
var newCamping = component.get("v.newItem");
helper.createItem(component, newCamping);
}
}
})