Open 500Foods opened 1 year ago
The only thing that doesn't quite seem to work properly is that the "hide menu" option at the top hides the entire menu all the time, whereas previously it would show an icon column when the screen was wide enough.
Will revisit this after their official AdminLTE 4 release as they've been fiddling with this code even since this TMS WEB Core Template project was first posted a few weeks ago.
At the moment, when switching Forms or SubForms, the DOMContentLoaded event is fired to try and get the AdminLTE JS to attach itself to whatever new components are on the page. The downside to this is that it wasn't designed for this. As a result, it re-attaches itself to any elements it finds, including those that it was already attached to previously.
As this attachment mechanism - addEventListener - uses anonymous functions rather than named functions, there isn't really any good way to remove the event handlers short of cloning the node in place. However, doing so removes other event handlers, including our own.
The resolution, for now, is to alter their JS code to add a class to the objects they've attached themselves to (the LTE class) and then only add new event listeners if that class is not present. Hack-ish, certainly. But it works. So we end up with an adminlte-custom.js that we use instead. A new function is inserted, and then the existing functions are replaced with references to this new function just by doing search and replace. Another approach would be to override the addEventListener function itself, but that's not very fun and besides, we only want these specific functions overridden.