Closed benmaier closed 4 years ago
while typing out the issue I've solved it, but I decided to post it nevertheless because it might help other people. It turns out that this is a long-known problem:
with an easy quick fix:
(remove the tabindex=-1
-attribute from the modal)
For my particular case, adding this line to the <script>
-section of _form.html
sufficed:
$(".modal").removeAttr("tabindex");
Thanks @benmaier, I'd with everyone would put as much effort into their questions as you. Also, double kudos for posting it, even though you already found the issue. I hope this will server other well should they encounter a similar problem.
if someone ends up here again, nowadays this problem (and a solution) are published directly from the select2 project: https://select2.org/troubleshooting/common-problems don't use the tabindex solution but set dropdownParent instead
Greetings, thank you so much for this great package that already saved me a lot of work! I'm currently working on developing simple admin-like CRUD-views for a project and am stuck on a particular problem (described below).
As a preamble I just want to add that I'm using the package
django-cruds-adminlte
. I've described my setup and my problem fully in this issue on their package: https://github.com/oscarmlage/django-cruds-adminlte.I'm posting here nevertheless because there hasn't been much activity there during the last month so I'm hoping I might be able to solve the problem myself if someone is able to point me in the right direction.
Goal I'm using a custom ModelForm that works as an "Inline" in a parent-ModelForm and pops up rendered as a bootstrap-modal. In this modal-form I'm using a ModelSelect2-widget.
Problem I've hoped that just pointing a
ChoiceField
to aSelect2Widget
would suffice for the ChoiceField to work. However, this is not the case. When rendered, theselect
-element "freezes", meaning the dropdown opens but I cannot type anything.Code Snippet The complete setup is described in this issue: https://github.com/oscarmlage/django-cruds-adminlte/issues/134. And this is a repository that reproduces the erroneous behavior: https://github.com/benmaier/example-django-crud-admin-lte-select2.
The
CRUDView
s I'm using inviews.py
basically auto-generate Model-specific forms that are rendered with crispy forms.For completion, I'm pasting here the way in which the modal inline-forms are generated in django-cruds-adminlte:
create.html
_form.html