0

I need to create a contract after getting confirmation from user like this:

I'm using simple lds to create a contract, when the user selects okay I should be able to create a contract. I have used overlayLibrary modal to show this cancel/ok modal, code is:

I followed this link to use overlayLibrary modal: link

how do we call the handleApplicationEvent in this code, if okay is clicked I want the lds component to open and show the contract create record.

enter image description here

OverLayLibraryModal.cmp

<aura:component access="global">
    <aura:registerEvent name="handleApplicationEvent" type="c:OverlayLibraryModalEvent"/>
    <lightning:overlayLibrary aura:id="overlayLib"/>

    <!--Component Start--> 
    <div class="slds-text-align_center slds-m-around_x-medium">
        <lightning:button name="cancel" label="Cancel" onclick="{!c.handleCancel}"/>
        <lightning:button name="ok" label="OK" variant="brand" onclick="{!c.handleOK}"/>
    </div>
    <!--Component End-->
</aura:component>

OverlayLibraryModalController.js

({
    handleCancel : function(component, event, helper) {
        //closes the modal or popover from the component
        var appEvent = $A.get("e.c:OverlayLibraryModalEvent");
        appEvent.setParams({
            "message" : "Cancel" 
        });
        appEvent.fire();
        component.find("overlayLib").notifyClose();
    },
    handleOK : function(component, event, helper) {
        //do something
        var appEvent = $A.get("e.c:OverlayLibraryModalEvent");
        appEvent.setParams({
            "message" : "Ok" 
        });
        appEvent.fire();
        //component.find("overlayLib").notifyClose();
    }
})

Parent component

<aura:handler event="c:OverlayLibraryModalEvent" action="{!c.handleApplicationEvent}"/>
    <lightning:overlayLibrary aura:id="overlayLib"/>
  • so you want to navigate to record detail page of the newly created record when you click okay? – User6670 Feb 11 '20 at 6:37
  • You need to handle application event in parent object where you can retrieved all parameters which you set while invoking application event. – dgk Feb 11 '20 at 6:38
  • @dgk I have defined handler in my parent cmp class like this: ``` <aura:handler event="c:OverlayLibraryModalEvent" action="{!c.handleApplicationEvent}"/> ``` how is this handleApplicationEvent goin to be called – user905 Feb 11 '20 at 22:46
  • @User6670 want to create record when okay is clicked, not navigate to be exact because for navigation I can use custom toast message. But I want to show kind of a modal with cancel/ok button – user905 Feb 11 '20 at 22:47
  • @user905: Need to fire from component where you are registering this. Say inside component from which you are creating overlay lib instance and provide handler on respective buttons. Use fire() for invoke event. – dgk Feb 12 '20 at 4:27

Your Answer

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

Browse other questions tagged or ask your own question.