Saturday, 25 April 2020

Toggle Checkbox in Lightning Aura Component

Toggle Lightning Component:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<!--Toggle.cmp-->
<aura:component>
    <aura:attribute name="toggleValue" type="String"/>

  <label class="slds-checkbox_toggle slds-grid">
     <span>Save File in Salesforce related to Task. </span>
                            <ui:inputCheckbox aura:id="chkbox" class="slds-input"/>
     <span id="toggle-desc" class="slds-checkbox_faux_container" aria-live="assertive">
     <span class="slds-checkbox_faux"></span>
     <span class="slds-checkbox_on">Enabled</span>
     <span class="slds-checkbox_off">Disabled</span>
     </span>
  </label>
</aura:component>

Toggle Lightning Component JS Controller:

1
2
3
4
5
6
7
8
<!--ToggleController-->

({
    selectChange : function(cmp, event, helper) {
        var checkToggleVal = cmp.find("chkbox").get("v.value");
        alert(checkToggleVal);
    }
})

No comments:

Post a Comment

Total Pageviews