Tag Archives: Javascript

JavaScript Confirm Dialog In Lightning Component

Lightning Component:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable">
    <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}"/>
    <!--Component End-->

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)) {
            return false;
        } else {
            //Write your confirmed logic


Difference Between JavaScript var and let

var : A variable defined using a var statement is known throughout the function it is defined in, from the start of the function.


    var i = 5;
//i can be used here

let : A variable defined using a let statement is only known in the block it is defined in, from the moment it is defined onward.


    let i = 5;
//i can be used here