Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <lightning:overlayLibrary aura:id="overlayLib"/>
- <lightning:button name="modal" label="Create Pet" onclick="{!c.handleShowModal}"/>
- handleShowModal : function (component, event, helper) {
- var modalBody;
- var modalFooter;
- $A.createComponents([
- ["c:IFBPetCreate", {"record": component.get("v.newPet"),
- "needsOwner": component.get("v.missingPetOwner"),
- "isEU": component.get("v.isEuUser"),
- "contList": component.get("v.contList"),
- "isLead": component.get("v.isLead")}],
- ["c:ModalFooter", {"recordId": component.get("v.recordId"),
- "newPet": component.get("v.newPet")}]
- ],
- function(components, status){
- if (status === "SUCCESS") {
- modalBody = components[0];
- modalFooter = components[1];
- component.find('overlayLib').showCustomModal({
- header: "New Pet",
- body: modalBody,
- footer: modalFooter,
- showCloseButton: false,
- cssClass: "my-modal,my-custom-class,my-other-class",
- closeCallback: function() {
- //alert('You closed the alert!');
- }
- })
- }
- }
- );
- },
- <aura:component implements="force:hasRecordId" controller="CasePetList_Controller">
- <aura:attribute name="recordId" type="String" />
- <aura:attribute name="newPet" type="Pet__c" default="{'sobjectType':'Pet__c', 'Active__c':true}" />
- <lightning:overlayLibrary aura:id="overlayLib"/>
- <lightning:button name="cancel" label="Cancel" onclick="{!c.handleCancel}"/>
- <lightning:button name="save" label="Save" variant="brand" onclick="{!c.handleSave}"/>
- </aura:component>
- handleCancel : function(component, event, helper) {
- component.find("overlayLib").notifyClose();
- console.log('handleCancel: component: '+component);
- var action = component.get("c.setNewPet");
- console.log('handleCancel: action: '+action);
- action.setParams({
- recId: component.get("v.recordId")
- });
- action.setCallback(this, function(response) {
- var state = response.getState();
- if(state === "SUCCESS") {
- component.set("v.newPet", response.getReturnValue());
- }else{
- console.log('Problem getting new pet, response state: ' + state);
- }
- });
- $A.enqueueAction(action);
- },
Add Comment
Please, Sign In to add comment