halfmoonui / halfmoon

Halfmoon is a highly customizable, drop-in Bootstrap replacement. It comes with three built-in core themes, with dark mode support for all themes and components.
https://www.gethalfmoon.com
MIT License
3.04k stars 118 forks source link

Sidebar won't open #23

Closed roelreijneveld closed 4 years ago

roelreijneveld commented 4 years ago

Hi there, I really like the Halfmoon framework. It's so beautiful, functional and yet simple. My compliments!

However, I have run into a problem which I cannot solve. I am developing a theme for a billing system (WHMCS) and have started designing the sidebar. However, it won't open when I press a button with onclick="halfmoon.toggleSidebar()". The dark mode switch is working correctly so I don't think it is a problem with the JavaScript library. Can someone tell me what the problem is? The URL is https://dev.proxeuse.nl/whmcs/.

Thanks in advance! Kind regards

visoft commented 4 years ago

This is similar to my issue in https://github.com/halfmoonui/halfmoon/issues/20, basically the halfmoon.pageWrapper is not being initialized. Are you using a framework like React? The issue with that is the HTML doesn't exist when the page is loaded, therefore the selector for pageWrapper doesn't get initialized.

halfmoonui commented 4 years ago

You need to add the <script src="path/to/halfmoon.min.js"></script> to the end of the DOM's body if you want the inline onclick functions to work. I recommend using the starter template generator. I re-built your page and added to the end of the DOM's body and it worked properly.

roelreijneveld commented 4 years ago

Thanks for your comments! I've moved the halfmoon.min.js to the end of the page from the <head> section. It works like a charm now.