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

Only one instance on a page will respond to callbacks #220

Open
boardfish opened this issue Jun 17, 2021 · 0 comments
Open

Only one instance on a page will respond to callbacks #220

boardfish opened this issue Jun 17, 2021 · 0 comments

Comments

@boardfish
Copy link

If I'm rendering two instances of the widget on the page, I've found that only the second instance that was rendered will respond to callbacks.

I'm initializing them from two separate instances of a Stimulus controller. In short, there are two elements on the page that each have a data-controller attribute. That tells Stimulus to mount an instance of a controller onto them.

When the controllers connect, they each create a new TimekitBooking() and initialize it with similar configuration. Part of this configuration is a set of callbacks that call methods on the controller instance.

I'd expect that if two widgets were initialized with separate callbacks, each widget's callbacks would run when the corresponding widget receives the event. But it seems as though only the most recently initialized instance of the widget runs the callbacks.

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

No branches or pull requests

1 participant