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

Handle Actions with Controllers
I'm going through this trail and I have gotten stuck on the Handle acitons with controllers module in the first section in the intermeidate developer trail. I am stuck onthe chalange for this module. The error i have not been able to get past is this: The campingListItem Lightning Component doesn't contain a button or its attributes are not set correctly when clicked.
I know the code i have now is not perfect, i have been messing with it trying everything i can think of for hours now. at this point this is what i have:
<aura:component >
<aura:attribute name="item" type="Camping_Item__c" />
<aura:attribute name="buttonDisabled" type="String" default="false"/>
<ui:outputText value="{! v.item.name}" />
<ui:outputCheckbox value="{!v.item.Packed__c}"/>
<ui:outputCurrency value="{!v.item.Price__c}"/>
<ui:outputNumber value="{! v.item.Quantity__c}" />
<ui:button label="Mark as packed" press="{!c.packItem}" disabled="{! v.buttonDisabled}" />
</aura:component>
and JS of
({
packItem : function(component, event, helper) {
//component.set("v.item.Packed__c", true);
component.set("v.buttonDisabled", "true");
}
})
the one line is commented out because i was trying to just focus and get past this one error.
I just can't seem to figure out how the challenge want me to disable the button. very frustrating when the module doesn't give an example of how to do this and the challenge expects you to figure it out. I've looked at all the additional resources for the module and looked in forms and google, and i guess this is my last hope. otherwise I guess I'll have to skip this challenge...
Thanks for any help.
I know the code i have now is not perfect, i have been messing with it trying everything i can think of for hours now. at this point this is what i have:
<aura:component >
<aura:attribute name="item" type="Camping_Item__c" />
<aura:attribute name="buttonDisabled" type="String" default="false"/>
<ui:outputText value="{! v.item.name}" />
<ui:outputCheckbox value="{!v.item.Packed__c}"/>
<ui:outputCurrency value="{!v.item.Price__c}"/>
<ui:outputNumber value="{! v.item.Quantity__c}" />
<ui:button label="Mark as packed" press="{!c.packItem}" disabled="{! v.buttonDisabled}" />
</aura:component>
and JS of
({
packItem : function(component, event, helper) {
//component.set("v.item.Packed__c", true);
component.set("v.buttonDisabled", "true");
}
})
the one line is commented out because i was trying to just focus and get past this one error.
I just can't seem to figure out how the challenge want me to disable the button. very frustrating when the module doesn't give an example of how to do this and the challenge expects you to figure it out. I've looked at all the additional resources for the module and looked in forms and google, and i guess this is my last hope. otherwise I guess I'll have to skip this challenge...
Thanks for any help.
The disabled attribute on the ui:button expects a boolean . So you might want to change either your attribute to a boolean type (Or) your code to <ui:button label="Mark as packed" press="{!c.packItem}" disabled="{! v.buttonDisabled=='true'}" />
Please mark the answer if this resolved your issue.
<aura:component >
<aura:attribute name="item" type="Camping_Item__c" />
<ui:outputText value="{! v.item.name}" />
<ui:outputCheckbox value="{!v.item.Packed__c}"/>
<ui:outputCurrency value="{!v.item.Price__c}"/>
<ui:outputNumber value="{! v.item.Quantity__c}" />
<ui:button label="Packed!" press="{!c.packItem}" />
</aura:component>
and JS of
({
packItem : function(component, event, helper) {
var a = component.get("v.item",true);
a.Packed__c = true;
component.set("v.item",a);
var btnClicked = event.getSource();
btnClicked.set("v.disabled", true);
}
})
a.Packed__c = true;
component.set("v.item",a)
Instead of just doing
?
What is the allowed syntax for v.attribute notation in controllers?