Enhance Select2 integration in caseSeriesModal to ensure proper dropdown behavior
This commit is contained in:
@@ -3,6 +3,21 @@
|
|||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<script>
|
||||||
|
(function($) {
|
||||||
|
if ($ && $.fn && $.fn.select2) {
|
||||||
|
var originalSelect2 = $.fn.select2;
|
||||||
|
$.fn.select2 = function(options) {
|
||||||
|
if (options && typeof options === 'object') {
|
||||||
|
if (this.closest('#caseSeriesModal').length > 0) {
|
||||||
|
options.dropdownParent = $('#caseSeriesModal');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return originalSelect2.apply(this, arguments);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})(window.jQuery);
|
||||||
|
</script>
|
||||||
<h2>Uploaded dicoms</h2>
|
<h2>Uploaded dicoms</h2>
|
||||||
User: {{user}}<br/>
|
User: {{user}}<br/>
|
||||||
<a href="{% url 'atlas:new_uploads' %}">Upload more dicoms</a><br/>
|
<a href="{% url 'atlas:new_uploads' %}">Upload more dicoms</a><br/>
|
||||||
@@ -774,13 +789,6 @@
|
|||||||
item.classList.toggle('selected', cb.checked);
|
item.classList.toggle('selected', cb.checked);
|
||||||
cb.dispatchEvent(new Event('change', { bubbles: true }));
|
cb.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prevent Bootstrap 5 from stealing focus from Select2 inputs inside modals
|
|
||||||
document.addEventListener('focusin', function (e) {
|
|
||||||
if (e.target && e.target.closest && (e.target.closest('.select2-container') || e.target.closest('.select2-search__field') || e.target.closest('.select2-dropdown'))) {
|
|
||||||
e.stopImmediatePropagation();
|
|
||||||
}
|
|
||||||
}, true);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Reference in New Issue
Block a user