Skip to content

Commit 22d58b8

Browse files
drusepthclaude
andcommitted
Fix 'showHowToJoinModal is not defined' error
- Switched to Materialize's built-in modal trigger mechanism - Added proper modal-trigger class to help button - Replaced inline onclick handler with data-target attribute - Properly initialized all modals using document.querySelectorAll - Added event listener for direct programmatic control - Used getInstance pattern for reliable modal manipulation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 46f420a commit 22d58b8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

app/views/browse/tag.html.erb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
<!-- Help button for how to join -->
4646
<div class="help-tooltip-container" style="position: absolute; top: 20px; right: 20px; z-index: 10;">
47-
<button class="btn-floating white z-depth-2 pulse" id="how-to-join-btn" style="height: 42px; width: 42px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none;" onclick="showHowToJoinModal()">
47+
<button class="btn-floating white z-depth-2 pulse modal-trigger" id="how-to-join-btn" style="height: 42px; width: 42px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none;" data-target="how-to-join-modal">
4848
<i class="material-icons <%= @accent_color %>-text">help_outline</i>
4949
</button>
5050
</div>
@@ -353,17 +353,17 @@
353353
filterLinks[0].style.backgroundColor = '<%= @accent_color == "grey" ? "#9e9e9e" : "var(--#{@accent_color}-lighten-4)" %>';
354354
filterLinks[0].style.fontWeight = '500';
355355

356-
// Define the showHowToJoinModal function in global scope
357-
window.showHowToJoinModal = function() {
358-
// Initialize and open the pre-defined modal
359-
var modalElement = document.getElementById('how-to-join-modal');
360-
var modalInstance = M.Modal.init(modalElement, {opacity: 0.6});
361-
modalInstance.open();
362-
};
356+
// Initialize all modals
357+
var modalElems = document.querySelectorAll('.modal');
358+
var modalInstances = M.Modal.init(modalElems, {opacity: 0.6});
363359

364-
// Initialize the modal when the page loads
365-
var howToJoinModal = document.getElementById('how-to-join-modal');
366-
M.Modal.init(howToJoinModal, {opacity: 0.6});
360+
// Add click handler to the help button
361+
document.getElementById('how-to-join-btn').addEventListener('click', function() {
362+
var modalInstance = M.Modal.getInstance(document.getElementById('how-to-join-modal'));
363+
if (modalInstance) {
364+
modalInstance.open();
365+
}
366+
});
367367
});
368368
<% end %>
369369

0 commit comments

Comments
 (0)