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

Events on foreach bound elements do not register correctly #1

Open
Olverine opened this issue Sep 13, 2022 · 0 comments
Open

Events on foreach bound elements do not register correctly #1

Olverine opened this issue Sep 13, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Olverine
Copy link
Owner

The problem

Event bindings do not seem to register on an element that also has a foreach binding. It does however work on child elements.
For example:

<div class="wifi-select">
  <div class="wifi-option" wifi-vm-foreach="$vm.networks" wifi-vm-event-bind="click::ssidUpdate($item.ssid)">
    <div style="width: 32px" wifi-vm-content-bind="$vm.wifiIcons[$item.strength]"></div>
    <div wifi-vm-content-bind="$item.ssid"></div>
    <div wifi-vm-content-bind="$item.private ? '&#128274;' : '&#128275;'"></div>
  </div>
</div>

The ssidUpdate event never gets fired since it is on the same element that is foreach bound.

Possible workaround

Put the binding on a child element.
For example:

<div class="wifi-select">
  <div class="wifi-option" wifi-vm-foreach="$vm.networks">
    <div wifi-vm-event-bind="click::ssidUpdate($item.ssid)">
      <div style="width: 32px" wifi-vm-content-bind="$vm.wifiIcons[$item.strength]"></div>
      <div wifi-vm-content-bind="$item.ssid"></div>
      <div wifi-vm-content-bind="$item.private ? '&#128274;' : '&#128275;'"></div>
    </div>
  </div>
</div>
@Olverine Olverine added the bug Something isn't working label Sep 13, 2022
@Olverine Olverine self-assigned this Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant