xxxxxxxxxx
<h1 id="hello">Hello</h1>
<script type="text/javascript">
// Guard against double DOM loads
var codeExecuted = false;
document.addEventListener('DOMContentLoaded', function(e) {
// Check if importmap stuff exisits without throwing an error.
// Then run main code w/ guard against multiple executions.
if ("importmapScriptsLoaded" in window) {
if (!codeExecuted) {
// Main code here
console.log($('#hello'));
// Don't forget to bump guard for one-time only JS execution !!
codeExecuted = true;
};
};
});
</script>
Il problema di Rails 7 che carica i JS di sistema prima della pagina html.erb