diff --git a/static/js/search.js b/static/js/search.js
index d7b893e0c1..2bf49c46fe 100644
--- a/static/js/search.js
+++ b/static/js/search.js
@@ -75,15 +75,18 @@ $( document ).ready(function() {
"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}" +
term+"(?:\\s?(?:[\\w]+)\\s?){0,"+numContextWords+"}");
item.context = text;
- return '
' +
- '» ' + item.title +
- '
' +
- (item.context || '') +'
' +
- '
';
+ var divcontext = document.createElement("div");
+ divcontext.className = "context";
+ divcontext.innerText = (item.context || '');
+ var divsuggestion = document.createElement("div");
+ divsuggestion.className = "autocomplete-suggestion";
+ divsuggestion.setAttribute("data-term", term);
+ divsuggestion.setAttribute("data-title", item.title);
+ divsuggestion.setAttribute("data-uri", item.uri);
+ divsuggestion.setAttribute("data-context", item.context);
+ divsuggestion.innerText = '» ' + item.title;
+ divsuggestion.appendChild(divcontext);
+ return divsuggestion.outerHTML;
},
/* onSelect callback fires when a search suggestion is chosen */
onSelect: function(e, term, item) {