xpodev / seamless

A Python package for creating and manipulating HTML components. It is working similar to React.js, but in Python.
https://seamless.readthedocs.io
MIT License
11 stars 1 forks source link

Add events support for dynamically added elements. #11

Closed neriyaco closed 7 months ago

neriyaco commented 7 months ago

When adding new elements with pyx-id the event won't fire because the addEventListener is only called once after the document is loaded. We should be able to attach event for components coming from the websocket api.

I'm thinking one of 2 ways:

  1. Using MutationObserver to check for changes in the DOM, might cause performace issues though.
  2. Adding check when getting a new component and adding the necessary events if the pyx-id attribute is presented.
neriyaco commented 7 months ago

It's fixed by #16