Commit 1e3a0061 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by alexeyomelchenko
Browse files

Bug 1645455: Fix html shown in autocomplete searchbox

* changes to Cecilia's commit
* proposal to fix bug differently ...

behatnotneeded

Change-Id: I4bc084e1d4505ed3de844f63f218ff05260b66c8
parent 466e66ca
......@@ -8,7 +8,7 @@
<script type="application/javascript">
{{if !$inblockconfig}}
jQuery(window).load(function () {
jQuery(window).on('load', function () {
{{/if}}
jQuery("#{{$id}}").select2({
ajax: {
......@@ -27,7 +27,15 @@
},
processResults: function(data, page) {
return {
results: data.results,
results: jQuery.map(data.results, function(item) {
// sometimes text contains html that has to be renderered in the result list (e.g. user profile)
// we're assigning text to resultsText variable that get rendered in results, and
// leave only text values in text variable. (in selection field will be displayed only text without markup)
return jQuery.extend(item, {
resultsText: item.text,
text: jQuery('<div>').html(item.text).text()
})
}),
pagination: {
more: data.more
}
......@@ -40,6 +48,9 @@
allowClear: {{$allowclear}},
{{if $hint}}placeholder: "{{$hint}}",{{/if}}
minimumInputLength: {{$mininputlength}},
templateResult: function(item) {
return item.resultsText || item.text;
},
{{$extraparams|safe}}
});
{{if !$inblockconfig}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment