0

I have ui:inputText component which is something like this:

<ui:inputText updateOn="keyup"
   keyup="{!c.keyPressController}"
   class="slds-input slds-combobox__input"
   aura:id="comboBox"
   value="{!v.searchKey}"
   placeholder="{!v.placeholder}"/>

Is it possible to make it readonly something like this?

<input type="text" class="slds-input slds-combobox__input" readonly="" value="hello" />
3

You can use enhanced version of ui:inputText which is lightning:input. It has readonly as attribute

<lightning:input name="quantity" value="1234567890"
 label="Quantity" maxlength="10" readonly="true" />

Same code can be written as

<lightning:input onchange="{!c.keyPressController}"
   class="slds-input slds-combobox__input"
   aura:id="comboBox"
   value="{!v.searchKey}"
   placeholder="{!v.placeholder}" readonly="true"/>
0

It is important for you to understand that the ui:inpiuttext and lightning:input components, when rendered, end up being broken down into html tags with specific classes and attributes.

I would encourage you to check the Lightning Components Developer Guide whenever you ask yourself these kinds of questions. "Does this component support this?"

as pointed out by @Himanshu, the lightning:input component, does indeed support this attribute.

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.