yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.8k stars 467 forks source link

Using data-html has no effect when rendering new option #1219

Closed eprikazc closed 3 years ago

eprikazc commented 3 years ago
  1. Set data-html=true for your select2 widget
  2. Return HTML in AJAX response

Problem: HTML is not interpreted but displayed as text: 2021-02-19_10-17

This seem to be related to https://github.com/yourlabs/django-autocomplete-light/issues/1171. Looks like its fix was not quite correct. As I understand, the problem happens because of $('<span>').text(...) call here - https://github.com/yourlabs/django-autocomplete-light/blob/3.8.1/src/dal_select2/static/autocomplete_light/select2.js#L28 If data-html is set we want to do $(<span>).html, not $(<span>).text()