I use Rails 7 and turbo. I want to use a Bootstrap 5 admin theme but having the following issue:
To bind the click event to the menu toggle button, there is some code like this:
let menuToggler = document.querySelectorAll('.layout-menu-toggle');
This works once but of course after a page change (with turbo) this dies not work anymore since the toggle button is loaded in the DOM and the binding does not work anymore.
I know that I can bind events to the parent (body) but I was wondering if there is another way to solve this. The entire admin theme is full of JS and I do not want to rewrite all the JS.
Does turbo have any solution for this kind of challenge?