Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error when using coreui with webpack and bootstrap admin template #354

Unanswered
geraldhanks asked this question in Q&A
Discussion options

I have installed webpack into my project and have included coreui in my app.js file using "import '@coreui/coreui'". Webpack builds my javascript bundle but I seem to be missing something since I am getting an error when using the bootstrap admin template and trying to hide the sidebar with onclick="coreui.Sidebar.getInstance(document.querySelector('#sidebar')).toggle()"

The sidebar fails to toggle and my browser debugger shows that the variable 'coreui' cannot be found.

Any ideas on what I could be missing?

You must be logged in to vote

Replies: 2 comments · 2 replies

Comment options

@geraldhanks Can you try this import * as coreui from '@coreui/coreui';

You must be logged in to vote
2 replies
@kantorge
Comment options

Thank you for the suggestion. I've been able to get it working with the following code.

import * as coreui from '@coreui/coreui'; window.coreui = coreui;

@jheathco
Comment options

This worked for me as well - thank you. Wonder why this is necessary?

Comment options

Don't use the inline onclick, just add some plain Javascript code in your app.js and add an event listener.

It is another way of thinking but you almost never need the inline stuff.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.