4

trying to implement the Modal using Lightning:overLayLibrary as per this link lightningOverlayLibrary i am facing the below issue

Uncaught (in promise) TypeError: Cannot read property 'la' of undefined
    at Object.dispatchGlobalEvent (aura_prod.js:757)
    at a (lightning-overlay-utils.js:2)
    at new Promise (<anonymous>)
    at Promise.all.then.a

Component

<aura:component>
    <lightning:button label="New REcord" name="modal"  onclick="{!c.handleShowModal}"></lightning:button>
</aura:component>

controller.js

({
doInit : function(component, event, helper) {

},
   handleShowModal: function(component, evt, helper) {
    var matterid = component.get("v.recordId");
    var modalBody;
    $A.createComponent("c:demoPagecomponent", {},
       function(content, status) {
           if (status === "SUCCESS") {
               modalBody = content;
               alert(modalBody);
               component.find('overlayLib').showCustomModal({
                header: "Application Confirmation",
                   body: modalBody, 
                   showCloseButton: true,
                   cssClass: "mymodal",
                   closeCallback: function() {
                       alert('You closed the alert!');
                   }
               })
           }                               
       });
    }
})

demoPagecomponent

<aura:component>
<div>
Hello
</div>
</aura:component>
5
  • Would you mind adding your code? We can replicate that in our org and see whats wrong. Thanks Commented May 29, 2018 at 15:23
  • updated please look into it . i think this line causing problem component.find('overlayLib').showCustomModal({
    – Raghav
    Commented May 29, 2018 at 15:47
  • Where you are getting this error? In lightning App? or Lightning Experience ?
    – A.Bretto
    Commented May 30, 2018 at 6:54
  • it is in Lightning App
    – Raghav
    Commented May 31, 2018 at 5:04
  • You are using component.find('overlayLib') but I cannot find this attribute in your markup... Commented Jun 3, 2018 at 6:42

2 Answers 2

2

I came across this question while finding the solution for the same and after a few hard luck, I found that I was trying to preview it using a Lightning:app and that's what throwing this error. If you try to access somewhere in a record page or quick action then it will work without throwing this error.

lightning:overlayLibrary will not work in the lightning:app.

I hope this tip will help someone for sure.

1

In order to Create a popup inside Lightning:app , you need to create a custom popup , Please follow this link and put into the modal body the component tag you want to display , I tried this and it worked ! .

http://sfdcmonkey.com/2017/04/15/modal-box-lightning-component-salesforce/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .