18

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.

25

The right syntax to do this is below

var btn = event.getSource();
btn.set("v.disabled",true);//Disable the button
| improve this answer | |
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.
| improve this answer | |

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.