Skip to content

Commit 7cbd984

Browse files
committed
Fix Bootstrap 5 compatibility issues
- Fix popover initialization to use Bootstrap 5 native API instead of jQuery-style initialization - Replace btn-xs with btn-sm (Bootstrap 5 removed btn-xs) - Fix in base.html, embed_instructions.html, and my_polls.js Resolves Sentry error: .popover is not a function
1 parent 24feb23 commit 7cbd984

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

approval_polls/staticfiles/my_polls.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ $(function () {
1616
"<p>This poll will be permanently deleted. " +
1717
"<button id='confirm-delete-" +
1818
pollId +
19-
"' type='button' class='btn btn-danger btn-xs'>Delete</button> " +
19+
"' type='button' class='btn btn-danger btn-sm'>Delete</button> " +
2020
"<button id='cancel-delete-" +
2121
pollId +
22-
"' type='button' class='btn btn-primary btn-xs'>Cancel</button>" +
22+
"' type='button' class='btn btn-primary btn-sm'>Cancel</button>" +
2323
"</p></div>";
2424

2525
if ($("#alert" + pollId).length == 0) {

approval_polls/templates/base.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,15 @@
128128
crossorigin="anonymous"></script>
129129
<script>
130130
$(function () {
131-
$('[data-toggle="tooltip"]').tooltip();
132-
$('[data-toggle="popover"]').popover();
131+
// Initialize tooltips and popovers with Bootstrap 5 syntax
132+
var tooltipElements = document.querySelectorAll('[data-bs-toggle="tooltip"]');
133+
tooltipElements.forEach(function(element) {
134+
new bootstrap.Tooltip(element);
135+
});
136+
var popoverElements = document.querySelectorAll('[data-bs-toggle="popover"]');
137+
popoverElements.forEach(function(element) {
138+
new bootstrap.Popover(element);
139+
});
133140
});
134141
</script>
135142
{% block extra_js %}

approval_polls/templates/embed_instructions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h4>Put this code in your site</h4>
1212
<div class = 'form-group'>
1313
<textarea id='textAreaCode' class = 'form-control' readonly></textarea>
1414
</div>
15-
<button id= "copyText" class="btn mt-2 btn-primary btn-xs">Copy to Clipboard</button>
15+
<button id= "copyText" class="btn mt-2 btn-primary btn-sm">Copy to Clipboard</button>
1616
</div>
1717
</div>
1818
{% endblock %}

0 commit comments

Comments
 (0)