d.klauss
d.klauss

Reputation: 15

Salesforce lightning Input with list doesn't work

I'm trying use input with datalist in a lightning component and doesn't seem to work. I've looked around and can't seem to find anything that says i can't. So basically,

<input list="acctlist"/>
<datalist id="acctlist">
<option value="somevalue"> 
</datalist>

does not work. I want to have an input in a form that a user can type but also able to select from a list returned from the controller. Is there a workaround that would be as simple or is this the following route the best i got. https://developer.salesforce.com/blogs/developer-relations/2015/06/salesforce-lightning-inputlookup-missing-component.html

Upvotes: 0

Views: 1273

Answers (1)

H.Rog
H.Rog

Reputation: 11

The list attribute of input tag is not compatible with lightning component. When you deploy the components, the attribute is removed.

If you want to use input with datalist, you need to add the attribute in Renderer.js.

datalist.cmp

<input aura:id="acctlistInput" />
<datalist id="acctlist">
  <option value="somevalue" />
</datalist>

datalistRenderer.js

afterRender : function(component, helper) {
  var acctlistInputCmp = component.find("acctlistInput");
  var acctlistInput = acctlistInputCmp.getElement();
  acctlistInput.setAttribute("list", "acctlist");
  return this.superAfterRender();
}

Upvotes: 1

Related Questions