Skip to content

Commit ee91de6

Browse files
author
dima
committed
custom html for suggestions
1 parent 505485e commit ee91de6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/jquery.autocomplete.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@
8787
transformResult: function (response) {
8888
return typeof response === 'string' ? $.parseJSON(response) : response;
8989
},
90+
suggestionHtml: function(i, suggestion, value, classes, options) {
91+
return '<div class="' + classes.suggestion + '" data-index="' + i + '">' + options.formatResult(suggestion, value) + '</div>';
92+
},
9093
showNoSuggestionNotice: false,
9194
noSuggestionNotice: 'No results',
9295
orientation: 'bottom',
@@ -613,11 +616,10 @@
613616

614617
var that = this,
615618
options = that.options,
619+
classes = that.classes,
616620
groupBy = options.groupBy,
617621
formatResult = options.formatResult,
618622
value = that.getQuery(that.currentValue),
619-
className = that.classes.suggestion,
620-
classSelected = that.classes.selected,
621623
container = $(that.suggestionsContainer),
622624
noSuggestionsContainer = $(that.noSuggestionsContainer),
623625
beforeRender = options.beforeRender,
@@ -650,10 +652,10 @@
650652
html += formatGroup(suggestion, value, i);
651653
}
652654

653-
html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
655+
html += options.suggestionHtml(i, suggestion, value, classes, options);
654656
});
655657

656-
this.adjustContainerWidth();
658+
this.adjustContainerWidth();
657659

658660
noSuggestionsContainer.detach();
659661
container.html(html);

0 commit comments

Comments
 (0)