5

I know by title it feels not acceptable but hear me out. I have registered below event in my cmp file

<aura:registerEvent name="showToast" type="force:showToast" />

and an helper method as

showToast : function(component, title, message, type) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "title": title,
            "message": message, 
            "type": type,
            "mode": "sticky",
            "duration": "50000"
        });
        toastEvent.fire();
    }, 

and i am calling this method on success callback of xyz functionality as

helper.showToast("",'SUCCESS', 'The Document has been Removed', "success");

but I see nothing on the page. It's a lightning page only.

I have even tried to give more duration so that I can inspect if it is there in the DOM or not but no I can not see.

I have checked SLDS.css, it's loading properly, I have event kept toast css classes in concerned component style also but to no avail.

Could you please provide some more directions on how to debug this to resolution.

Thanks, Akash

  • No need to register the event....... – Eric Jan 31 '17 at 11:48
  • No still not working, if I remove it then its throws an error; setParams of undefined – Test Jan 31 '17 at 12:35
  • What browser are you using? Try starting from a empty component with a button that calls showToast using code from here: developer.salesforce.com/docs/atlas.en-us.lightning.meta/… - then add your stuff to it and see where it breaks. Also, seems stupid but use " instead of ' just in case. – Eric Jan 31 '17 at 12:39
  • Odd, cause I do not have the event registered and the toast works fine. is the helper in a different component? We may need to see the whole code – Eric Jan 31 '17 at 12:43
  • 3
    @Test Where are you running the component ? Is it inside standalone app or your own custom app or vf page? – Praveen Jan 31 '17 at 12:45
4

You are view the lightning page from preview? if yes, the toast is not working because the event is handled by one.app.

Quoting from documentation:

This event is handled by the one.app container. It’s supported in Lightning Experience, Salesforce1, and Lightning communities.

You can create your own toast component if you want to preview the page, or simply create a tab for the lightning page.

Check documentation for more details: force:showToast

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.