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

Reinitialize Sidebar Component #257

Closed
mocfaisal opened this issue Sep 29, 2023 · 5 comments
Closed

Reinitialize Sidebar Component #257

mocfaisal opened this issue Sep 29, 2023 · 5 comments

Comments

@mocfaisal
Copy link
Contributor

Hi, can you make this one accessible to reinit the sidebar?

window.sidebar = new Sidebar(sidebarEl)

currently it only loads once, I want it to be able to be reinitialize when entering another page.
because there is an issue when build SPA application, which must be reinit again

@billalxcode
Copy link
Contributor

Hi, can you clarify what you mean? I don't understand what you mean. Will a reusable function be created later?

@mocfaisal
Copy link
Contributor Author

Hi, can you clarify what you mean? I don't understand what you mean. Will a reusable function be created later?

make Sidebar method as a global function
there is an issue when build SPA application, that need to reinitialize the sidebar

like select2 or DataTable js plugin that can destroy and reinitialize

@billalxcode
Copy link
Contributor

window.sidebar = new Sidebar(sidebarEl)

Change

window.sidebar = new Sidebar(sidebarEl)

to

window.Sidebar = Sidebar

You can call it in the following way

const sidebar = new window.Sidebar( document.getElementById("sidebar") )

@mocfaisal
Copy link
Contributor Author

mocfaisal commented Sep 29, 2023

window.sidebar = new Sidebar(sidebarEl)

Change

window.sidebar = new Sidebar(sidebarEl)

to

window.Sidebar = Sidebar

You can call it in the following way

const sidebar = new window.Sidebar( document.getElementById("sidebar") )

Thanks mate this code is working 🔥

Current code

window.Sidebar = Sidebar
if (sidebarEl) {
const sidebar = new window.Sidebar(sidebarEl)
}

Found another bug :
Submenu dropdown toggle not smooth
Style attribute are gone

First initialize

<ul class="submenu submenu-closed" style="--submenu-height: 86px;">

Second initialize

<ul class="submenu submenu-closed">

My suggestion better implement destroy method too

@alfianchii alfianchii assigned alfianchii and unassigned alfianchii Sep 29, 2023
@mocfaisal
Copy link
Contributor Author

Fixed the bug, i'll update the code later

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

3 participants