You need to sign in to do that
Don't have an account?

Lightning button issue
****This is my component details****
Attribute:
<aura:component >
<aura:attribute name="ABC" type="string" default="false"/>
**This is lightning button details**
<lightning:button label="Submit" onclick="{!c.doSubmit}"></lightning:button>
**THis is my funtion doSubmit in controller**
({
doSubmit : function(cmp, evt, hlpr) {
//accessing the value in attribute ABC
var initialABCValue = cmp.get("v.abc");
if(initialABCValue == "true"){
alert("Value is true");
//setting value of ABC to false
cmp.set("v.abc","false");
}
else{
alert("Value is False");
//setting value of ABC to true
cmp.set("v.abc","true");
}
}
})
Now on click on button "Submit" on Page i should get initially false value ,on next click it should be true value accordingly .As my function says so
I am not getting changin vlaues on pop up just getting "False"
Can you helpmeguys with correction in code.[![enter image description here][1]][1]
Attribute:
<aura:component >
<aura:attribute name="ABC" type="string" default="false"/>
**This is lightning button details**
<lightning:button label="Submit" onclick="{!c.doSubmit}"></lightning:button>
**THis is my funtion doSubmit in controller**
({
doSubmit : function(cmp, evt, hlpr) {
//accessing the value in attribute ABC
var initialABCValue = cmp.get("v.abc");
if(initialABCValue == "true"){
alert("Value is true");
//setting value of ABC to false
cmp.set("v.abc","false");
}
else{
alert("Value is False");
//setting value of ABC to true
cmp.set("v.abc","true");
}
}
})
Now on click on button "Submit" on Page i should get initially false value ,on next click it should be true value accordingly .As my function says so
I am not getting changin vlaues on pop up just getting "False"
Can you helpmeguys with correction in code.[![enter image description here][1]][1]
This is very simple, As you know java script is case sensetive and as per java script you are using wrong veriable that's why this is always returning you false value.
Simply Change your Vaiable Name in Component from ABC to abc do not modify your controller code ONLY AND ONLY Component Code.
Thanks
All Answers
This is very simple, As you know java script is case sensetive and as per java script you are using wrong veriable that's why this is always returning you false value.
Simply Change your Vaiable Name in Component from ABC to abc do not modify your controller code ONLY AND ONLY Component Code.
Thanks