framework icon indicating copy to clipboard operation
framework copied to clipboard

Cannot bind to list attribute of input element

Open llicht opened this issue 9 years ago • 3 comments

Hi,

I'm submitting a bug report

  • Library Version: 1.0.5
  • Browser: Chrome 54 on Windows 7

Current behavior: If I place the following in a template file: (where listIdVar is a string variable with any value)

    <input value.bind="input" list.bind="listIdVar"></input>
    <datalist id.bind="listIdVar"> <!-- options... -->  </datalist>

I get the following error: TypeError: Cannot assign to read only property 'list' of object '#<HTMLInputElement>' Same happens if I use list="prefix-${listIdVar}" instead.

Expected/desired behavior: I wanted regular one-way binding from my variable to the "list" attribute of the input element. However, it seems that aurelia tries to do this via assigning to the read-only 'list' property. Per http://stackoverflow.com/questions/24925336/set-html5-input-list-value-with-javascript, it seems the correct way to do this is via setAttribute.

Thanks.

llicht avatar Oct 30 '16 15:10 llicht

Right- for some reason HTMLInputElement.list is read-only:

list https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement

You'll need to set the input's list via the HTML attribute instead of it's DOM property:

<input value.bind="input" list.bind="listIdVar & attr">

Make sure you have aurelia-templating-resources 1.1.0 or higher.

Keeping this open so we can add logic to the binding engine to use the html attribute by default for this scenario instead of the standard behavior which assigns the dom property.

jdanyow avatar Nov 01 '16 00:11 jdanyow

WoW.. Hidden gem of cheap autocomplete UI Support is poor though )-:

Definitely made my day

Might me closed though

Alexander-Taran avatar Mar 02 '18 23:03 Alexander-Taran

I'd like to keep this open as a legit enhancement to the binding engine in the future.

EisenbergEffect avatar Mar 03 '18 21:03 EisenbergEffect