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

Add attribute data-initialized=true to the component has been initialized #947

Open
honeypc opened this issue Aug 21, 2024 · 0 comments
Open

Comments

@honeypc
Copy link

honeypc commented Aug 21, 2024

Is your feature request related to a problem? Please describe.
I’m currently facing challenges with reinitializing Flowbite components dynamically in my project. When attempting to reinitialize components, it’s difficult to determine if a component has already been initialized, which leads to potential issues such as duplicate initializations or unnecessary reinitialization processes.

Describe the solution you'd like
I would like Flowbite to add a data-initialized="true" attribute to each component after it has been initialized. This attribute would serve as a flag indicating that the component has already undergone the initialization process, making it easier to manage and control reinitialization in dynamic applications.

Describe alternatives you've considered
An alternative solution could involve manually tracking the initialization state of each component within our application code. However, this approach is less efficient, more error-prone, and requires additional logic to maintain, especially as the number of components grows.

Additional context
Adding the data-initialized="true" attribute would greatly simplify the management of component states in dynamic environments where components are frequently added, removed, or updated. It would also enhance the flexibility of Flowbite in projects that require custom initialization logic. Here is a sample implementation:
Eg: initDropdowns
document .querySelectorAll('[data-dropdown-toggle]:not[ data-initialized="true"]')
It helps after Turbo stream renders the callback initFlowbite not re-initialized existing dropdown while user use it

@honeypc honeypc changed the title Add attribute data-initialized=true to the component was Add attribute data-initialized=true to the component has been initialized Aug 21, 2024
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