-
hi @codingjoe, i would love your assistance as well. i am also trying to implement select2 with this package django_select2 via formsets here is a sample of my code <div class="col-md-8">
<div class="card">
<div>
</div>
<div>
<form class="card-box" method="POST">
{% csrf_token %}
{{ formset.management_form }}
{% for form in formset %}
<div class="row form-row spacer">
<!-- form variable -->
{{ form.as_p }}
<div class="input-group-append">
<button class="btn btn-success add-form-row">+</button>
</div>
</div>
{% endfor %}
<input class="btn btn-primary" type="submit" name="submit" value="Submit">
<br>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
{{ form.media.js }}
</div>
</div> forms.py
also i am using django 3.1 and python 3.6 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
i guess there is no solution to this........... |
Beta Was this translation helpful? Give feedback.
-
Hi @DarnelleF, Yes, there is an answer, this is actually a very common question. I was simply on vacation and didn't have time to catch up will all my work until now. If you add new select inputs to the DOM you need to initialize them. We only initialize all select inputs a single time once the DOM is loaded. Everything you inject via JS afterwards, you will need to initialize yourself. Just look into the JS file to see how to initialize new Select2 fields. Best |
Beta Was this translation helpful? Give feedback.
Hi @DarnelleF,
Yes, there is an answer, this is actually a very common question. I was simply on vacation and didn't have time to catch up will all my work until now.
If you add new select inputs to the DOM you need to initialize them. We only initialize all select inputs a single time once the DOM is loaded. Everything you inject via JS afterwards, you will need to initialize yourself. Just look into the JS file to see how to initialize new Select2 fields.
Best
Joe