Upgraded to Rails 7.0.4.2
This commit is contained in:
@@ -40,8 +40,31 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
//$(document).on("turbo:load", () => {
|
||||
//console.log("turbo!");
|
||||
//});
|
||||
<script type="text/javascript">
|
||||
|
||||
// Guard against double DOM loads
|
||||
// https://stackoverflow.com/questions/71876873/rails-7-7-0-2-3-importmap-jquery-is-not-defined-in-view
|
||||
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'));
|
||||
|
||||
$(".subprincipleitem").click(function(event) {
|
||||
alert(event.target.id);
|
||||
});
|
||||
|
||||
|
||||
// Don't forget to bump guard for one-time only JS execution !!
|
||||
codeExecuted = true;
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user