• +91-8376990324
  • amitdsy@gmail.com
Home • • JavaScript Confirm Dialog In Lightning Component

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
        }
    },
})
Tags:
Apply For Trainer