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.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.


The right syntax to do this is below

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

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.

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.