diff --git a/docs/_includes/options/selections/templating.html b/docs/_includes/options/selections/templating.html index 19eb8f23..6df19a32 100644 --- a/docs/_includes/options/selections/templating.html +++ b/docs/_includes/options/selections/templating.html @@ -27,11 +27,24 @@ $('select').select2({ I am using HTML in my selection template but it isn't displaying it - {% include options/not-written.html %} +

+ If you want to use HTML in your selection template, you will need to return a jQuery object. Otherwise, Select2 will assume that your template only returns text and will escape it. +

+ +{% highlight js linenos %} +function template(data, container) { + return $('') + .text(data.text); +} + +$('select').select2({ + templateSelection: template +}); +{% endhighlight %}

How can I access the container where the selection is displayed?

{% include options/not-written.html %} - \ No newline at end of file +