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

DOM Event Delegation #335

Open
JaneOri opened this issue Mar 30, 2019 · 2 comments
Open

DOM Event Delegation #335

JaneOri opened this issue Mar 30, 2019 · 2 comments

Comments

@JaneOri
Copy link

JaneOri commented Mar 30, 2019

Since can-component events deprecated:
https://canjs.com/doc/can-component.prototype.events.html
There isn't a happy path solution for the DOM event delegation that it provided

@JaneOri
Copy link
Author

JaneOri commented Mar 30, 2019

stache syntax could be interesting. like:

<ul on:delegated:click=".clickme; doSomething()">
  <li>asdf</li>
  <li class="clickme">Hi</li>
  <li class="clickme">Hello</li>
</ul>

downside: any existing event delegation to direct children of the component element can't use this since the component element isn't part of the view.

@rjgotten
Copy link

rjgotten commented Jun 16, 2020

@James0x57
Could set this up with the connectedCallback - e.g.

connectedCallback( element ) {
  this.listenTo( element, ".delegated", "click", event => {
    // ...
  });
});

Except registering delegated listeners currently does not work correctly at all with the underlying event bindings mixin. See also my findings in canjs/can-event-queue#35

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

2 participants