I'm making a SELECT like this:
<select class="select form-control js-example-basic-multiple" multiple="multiple" id="id_tags" name="tags">
{% for tag in photo.tags.all %}
<option selected value="http://localhost:8001/api/tags/{{ tag.id }}/">{{ tag.name }}</option>
{% endfor %}
</select>
I then fire up my select2 instance:
$(".js-example-basic-multiple").select2({
multiple : true,
ajax : { ..... }
});
And I see this:
AJAX is definitely working though, and new items can be added:
Also the Select2 instance has the right data even for the items that only have a cross:
IN >>> $(".js-example-basic-multiple").val()
OUT >>> ["http://localhost:8001/api/tags/4142/", "http://localhost:8001/api/tags/4145/", "http://localhost:8001/api/tags/4160/", "http://localhost:8001/api/tags/4213/", "http://localhost:8001/api/tags/4344/", "http://localhost:8001/api/tags/6602/"]
In case it helps someone else, this is what I had to do to fix this:
This is my code - all I had to do was comment out the
templateSelection
- which it turns out wasn't necessary anyway.