function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Conditional attribute default value


I have a modal that is displayed via two separate buttons - the component contains an attribute that determines which button opened the modal (via an event being fired) and an attribute containing the value of a picklist. I want the picklist to default to an option when one button is pressed, and not default to an option when the second button is pressed (remain blank until the user changes it).

How can I accomplish this while still only using this one comonent? I tried declaring the attributes in an aura:if tag that checks which button opened the modal, but it wouldn't compile.
James LoghryJames Loghry

Could you paste your code / markup?

If I'm understanding correctly, you'd just use an aura:attribute (of type string), name it something like defaultPicklistValue, and then pump that right into your picklist.  Then when you call the component, you'd either pass in blank or the default attribute