• Shreya Kakade
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hello Everyone,

I am trying to add the Toast message to the lightning Component But its not working here is the my code of the Function.

deteteQuestion : function(component, event, helper){
        
        var action = component.get("c.delSlctRec");
        var idx = event.target.id;
        action.setParams({ "slctRec" : idx});
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
                        title: "Success!",
                        message: "Congrats, it works!",
                        type: "success"
                    });
        //var result = confirm("Are you sure you want to delete?");
       // if(toastEvent) {
            action.setCallback(this, function(response){
                var state =  response.getState();
                if(state === "SUCCESS")
                {
                    component.set("v.ques",response.getReturnValue());
                    
                    toastEvent.fire();
                    //document.getElementById("msg").innerHTML = "Record deleted successfully";
                    //alert('Successfully Deleted.');
                    // window.location.reload();
                    
                }else if (state=="ERROR") {
                    //console.log(action.getError()[0].message);
                    alert('error');
                }
            }); 
            
            $A.enqueueAction(action);
       // }
    },