I am trying to display some text on Page by using Lighting componets.i am not getting that text on click on check box Below is my code .Let mek nwo where is my code wrong.

A>Component attribute define

<aura:attribute name="CheckBoxValue" type="Boolean" default="false"/>

Lightning tag with aura id defined in it

<lightning:input aura:id="checkBoxAM" label="Are you new to this course" name="HaveYouTakenCourseBefore" type="checkbox" onchange="{!c.onClickCheckBox}"/>

B>This is my Aura if conditiontag along with text to be displayed

<aura:if isTrue="{!v.CheckBoxValue}">
            Hello  You have checked this box

C>THis is my JS function in Controller

onClickCheckBox: function(component,event,helper) {

    // accesing the value of attribute HaveYouTakenCourseBefore;
    // Call function defined in helper;
    // hlpr.<Function Name in helper>
    console.log("This text is from helper function");


D>This is my FUnction defined in helper

onClickCheckBoxhelper : function(component) {

        //body of helper resourse
        // define logic of your function
        console.log("This text is from helper function");
        var checkBoxValue = component.find("checkBoxAM").get("v.checked");

E> Calling this Component in my Lightning App

PFA screen shot enter image description here

  • What did you do to my question ? What is edited not getting – AM_SFDC Apr 21 at 14:04

Hi I see that the attribute you're validating on the IF is CheckBoxValue but the one your seeting on your helper method is checkBoxAM.

My recomendation would be to modify the helper method to this:


| improve this answer | |
  • No is nt working by changing that – AM_SFDC Apr 21 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.