I have a custom Object, I was trying to override the NEW
standard button with lightning component.
On Click of New button , below modal popup is opened and save the Data is working.
Issue: On Click of cancel button I'm just calling cancelDialog
method in js. Expected is to close the modal. but It's doesn't do anything, It still remains in same Page.
Can anyone Please help me on this.
cancelDialog : function(component, helper) {
var home = $A.get("e.force:navigateToObjectHome");
home.fire();
},
Component
<aura:attribute name="items" type="NewData__c[]"/>
<aura:attribute name="enroll" type="NewData__c" default="{'sobjectType': 'NewData__c',
'NewData_Name__c':'',
'NewData_Email__c':''}" />
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<header class="slds-modal__header">
<lightning:buttonIcon iconName="utility:close"
onclick="{!c.cancelDialog}"
alternativeText="close"
variant="bare-inverse"
class="slds-modal__close"/>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">New Enrollment</h2>
</header>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<lightning:input aura:id="field" messageWhenValueMissing ='Name cant be blank.' required="true" value="{!v.enroll.NewData_Name__c}"
label="Name" />
<lightning:input type="email" aura:id="field" messageWhenValueMissing ='Email cant be blank.' required="true" value="{!v.enroll.NewData_Email__c}" label="Email" />
</div>
<footer class="slds-modal__footer">
<lightning:button variant="neutral" label="Cancel" onclick="{!c.cancelDialog}" />
<lightning:button variant="brand" label="Save" onclick="{!c.createData}" />
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>