Commit ac8ad8fc authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1645455: Fix html shown in autocomplete searchbox"

parents 4c99af9c 1e3a0061
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<script type="application/javascript"> <script type="application/javascript">
{{if !$inblockconfig}} {{if !$inblockconfig}}
jQuery(window).load(function () { jQuery(window).on('load', function () {
{{/if}} {{/if}}
jQuery("#{{$id}}").select2({ jQuery("#{{$id}}").select2({
ajax: { ajax: {
...@@ -27,7 +27,15 @@ ...@@ -27,7 +27,15 @@
}, },
processResults: function(data, page) { processResults: function(data, page) {
return { 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: { pagination: {
more: data.more more: data.more
} }
...@@ -40,6 +48,9 @@ ...@@ -40,6 +48,9 @@
allowClear: {{$allowclear}}, allowClear: {{$allowclear}},
{{if $hint}}placeholder: "{{$hint}}",{{/if}} {{if $hint}}placeholder: "{{$hint}}",{{/if}}
minimumInputLength: {{$mininputlength}}, minimumInputLength: {{$mininputlength}},
templateResult: function(item) {
return item.resultsText || item.text;
},
{{$extraparams|safe}} {{$extraparams|safe}}
}); });
{{if !$inblockconfig}} {{if !$inblockconfig}}
......
Supports Markdown
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