2
<aura:component >    
    <lightning:input type="toggle"
                     name="toggle1"
                     aura:id="toggle1"
                     label="Testing Toggle"
                     />
    <lightning:button label="My Button" name="btn1" aura:id="btn1"
                      onclick="{!v.clickHandle}"/>    
</aura:component>

({
    clickHandle : function(component, event, helper) {      
        var btn = component.find('btn1');
        btn.set('v.disabled', true);
    }
})
4
  • What happens instead? Have you made any attempt to debug this problem? Are you getting any errors?
    – Adrian Larson
    Commented Jan 1, 2018 at 14:48
  • Nothing happens when I click on the button.. Commented Jan 1, 2018 at 14:55
  • That doesn't at all answer the question of if you have looked at the logs.
    – Adrian Larson
    Commented Jan 1, 2018 at 14:57
  • Hello.. Thanks for your reply.. Yes. I checked console logs (and debug logs as well) and there isn't any error message except some distrust message. The SSL certificate used to load resources from https://j*******-dev-ed.lightning.force.com will be distrusted in M70. Once distrusted, users will be prevented from loading these resources. See g.co/chrome/symantecpkicerts for more information. Commented Jan 1, 2018 at 15:10

1 Answer 1

6

The v. prefix is used to access aura:attribute values. To invoke a controller method you need to use the c. prefix i.e.:

onclick="{!c.clickHandle}"

See e.g. Trailhead's Handle Actions with Controllers.

I don't know why the button is silently failing for you. For me I got an error dialog that hinted at the problem:

Access Check Failed! AttributeSet.get(): attribute 'clickHandle' of component 'markup://c:wizControls {62:465;a}' is not visible to 'markup://c:wizControls {62:465;a}'.

It is well worth getting familiar with your browser's development tools that allow you to set breakpoints and examine values and log to the console. Otherwise even small mistakes can take a long time to figure out.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .