Ad Code

How to add input checkbox and its handler in salesforce lightning component | working with ui:inputCheckbox

Hey guys,

Please find the code related to adding custom input check box and its related handlers.

In your component page: 

<aura:component implements="flexipage:availableForAllPageTypes">
        <ui:inputCheckbox aura:id="DRcheckbox" label="Dispatch required" change="{!c.onCheck}"/>

Client side controller page:

    onCheck: function(cmp, event, helper){
        var checkboxCmp = cmp.find("DRcheckbox");


Based on the value received in the client controller page you can implement your logic.

This code is for your reference, more details are mentioned in the below video

Subscribe to my Youtube channel and get updated with salesforce tutorials - click here


Post a Comment


  1. Hey Naveen,

    How can I make sure to keep the checkbox checked within the record I'm checking it? As of right now, this lightning component checks the checkbox field, but once I refresh the page, the checkbox is unchecked again.

    Let me know if you can help me with this.


  2. Hi Gustavo, Here I have mentioned only the handler part, no logic to insert the record to database.

    we need to implement complete functionality which stores the record. May be you can try with Lightning Data Service.