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

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.

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.