You need to sign in to do that
Don't have an account?
Li Lee
lightning:overlayLib show error when run in Visualforce Page
Hi all,
I want to show a Modal dialog in my aura component, and I find document in Lightning Component Library, here is the link: https://developer.salesforce.com/docs/component-library/bundle/lightning:overlayLibrary/documentation
I follow the code under Display Modal topic. My code as follow:
Lightning Application
Please corrected me if my code is wrong and may I ask for any idea how to fixed this?
I want to show a Modal dialog in my aura component, and I find document in Lightning Component Library, here is the link: https://developer.salesforce.com/docs/component-library/bundle/lightning:overlayLibrary/documentation
I follow the code under Display Modal topic. My code as follow:
Lightning Application
<aura:application extends="ltng:outApp" > <aura:dependency resource="c:ModalComponent"/> </aura:application>Lightning Component ModalComponent
<aura:component> <lightning:overlayLibrary aura:id="overlayLib"/> <lightning:button name="modal" label="Show Modal" onclick="{!c.handleShowModal}"/> </aura:component>ModalComponentController.js
({ handleShowModal: function(component, evt, helper) { var modalBody; $A.createComponent("c:modalContent", {}, function(content, status) { if (status === "SUCCESS") { modalBody = content; component.find('overlayLib').showCustomModal({ header: "Application Confirmation", body: modalBody, showCloseButton: true, cssClass: "mymodal", closeCallback: function() { alert('You closed the alert!'); } }) } }); } })Lightning Component modalContent
<aura:component> <lightning:icon size="medium" iconName="action:approval" alternativeText="Approved" /> Your application has been approved. </aura:component>Visualforce Page to embed lightning
$Lightning.use("c:TestModalDialog", function() { $Lightning.createComponent("c:ModalComponent", {}, "flow-component-container"); });But when I check Button it show follow error in Browser console.
Please corrected me if my code is wrong and may I ask for any idea how to fixed this?
There appears to be no issue with your code. However, I feel that the error you are seeing is very similar to what is described in this post
It should work fine if you remove VF out of the equation based on the explanation below
lightning:notificationsLibrary is not supported in Lightning Out (e.g. in a Visualforce page). Please review the documentation for this component. You'll need to use an alternative component to display modals in Visualforce, such as an open-source modal component.
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you
All Answers
There appears to be no issue with your code. However, I feel that the error you are seeing is very similar to what is described in this post
It should work fine if you remove VF out of the equation based on the explanation below
lightning:notificationsLibrary is not supported in Lightning Out (e.g. in a Visualforce page). Please review the documentation for this component. You'll need to use an alternative component to display modals in Visualforce, such as an open-source modal component.
Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Thanks for your information.