Skip to content

Commit

Permalink
Fix select2 widget so it works inside a Bootstrap modal
Browse files Browse the repository at this point in the history
  • Loading branch information
sde1000 committed Jun 25, 2024
1 parent 61875ea commit e4d6362
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion quicktill/tillweb/templates/tillweb/select2_widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
</select>
<script type="text/javascript">
$(document).ready(function(){
$("#{{widget.attrs.id}}").select2({{widget.select2_args|safe}});
const s2w = $("#{{widget.attrs.id}}");
const args = {{widget.select2_args|safe}};
var dropdownParent = $(document.body);
if (s2w.parents('.modal:first').length !== 0) {
dropdownParent = s2w.parents('.modal:first');
}
args['dropdownParent'] = dropdownParent;
s2w.select2(args);
});
</script>

0 comments on commit e4d6362

Please sign in to comment.