Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot bind to list attribute of input element #646

Open
llicht opened this issue Oct 30, 2016 · 3 comments
Open

Cannot bind to list attribute of input element #646

llicht opened this issue Oct 30, 2016 · 3 comments

Comments

@llicht
Copy link

llicht commented Oct 30, 2016

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.

@jdanyow
Copy link
Contributor

jdanyow commented Nov 1, 2016

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.

@Alexander-Taran
Copy link
Contributor

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

Definitely made my day

Might me closed though

@EisenbergEffect
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants