19

This may be broader question on how we set HTML attributes inside Lightning? The docs state ui:button has disabled property and it works fine in VFP for all VF components. But how do I set this attribute inside Lightning JS Controller? Nothing seem to work try several options in component controller JS; ...

var btn = event.getSource();
btn.disabled = true;
btn.disabled.set(true);
btn.attributes.disabled = true;

... many others but cannot effect the button state to set disabled on click event. No syntax errors (figure no compiled code JS) just not working.

2 Answers 2

26

The right syntax to do this is below

var btn = event.getSource();
btn.set("v.disabled",true);//Disable the button
0

More one trick... if input field don't return to enable with disabled = false use disabled = ""

btn.set("v.disabled",""); //but this don't function with toggle, function with select that i tested

btn.set("v.disabled","false"); //this in input select for sample don't function.

You must log in to answer this question.

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