JavaScript Confirm Dialog In Lightning Component
Biswajeet
September 19, 2019 1 Comment on JavaScript Confirm Dialog In Lightning Component
Lightning Component:
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable"> <!--Attributes--> <aura:attribute name="showConfirmDialog" type="boolean" default="false"/> <!--Component Start--> <div class="slds-m-around_xx-large"> <lightning:button name="delete" variant="brand" label="Delete" onclick="{!c.handleConfirmDialog}"/> </div> <!--Component End--> </aura:component>
Lightning JS Controller:
({ handleConfirmDialog : function(component, event, helper) { var selectedEventId = event.target.id; var msg ='Are you sure you want to delete this item?'; if (!confirm(msg)) { console.log('No'); return false; } else { console.log('Yes'); //Write your confirmed logic } }, })
Output: