[BUG] The opened Treeview menu won't collapse when the Treeview was initiated more than once
See original GitHub issueHi guys, I run Adminlte with Laravel using Inertiajs with Vue (SPA). the app is loading the adminlte on the login page so after logging in and being redirected to the dashboard the treeview needs to be initiated. I initiate the treeview with this:
$('[data-widget="treeview"]').each(function () { adminlte.Treeview._jQueryInterface.call($(this), 'init') })
and then the treeview is working properly.
but, the problem is when I refresh the page on the dashboard, the treeview can open but won’t collapse.
I think it’s because the treeview init runs more than once, first when the page refreshed and then when my code initiates the treeview again. how to check whether the treeview was initiated or not?, so I can condition my code to only run when the treeview is not initiated yet, or is there any other solution with this?, sorry for my bad English, I appreciate the help.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11
Top GitHub Comments
faced same problem while working with laravel & Vue 3 with inertiajs. found a fix for this after working it on 3 days, please checkout.
Add below lines in <script setup> of Vue component.
Hope this works for others too.
Update: there is still a problem with the code above, so here is my solution, so I make a function to initiate the TreeView in app.js:
and run that function with the Lodash once function:
after that, I make a global property to call that Lodash function:
and then I use that in my component: