From 937574fa0d333a6c5c45c428e948f4580c28d176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Marinetti?= Date: Wed, 20 Jul 2016 16:38:29 +0200 Subject: [PATCH] issue #451, put formatGroup available in option --- src/jquery.autocomplete.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index 7265d0e..6d78c20 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -67,6 +67,7 @@ deferRequestBy: 0, params: {}, formatResult: Autocomplete.formatResult, + formatGroup: Autocomplete.formatGroup, delimiter: null, zIndex: 9999, type: 'GET', @@ -143,6 +144,18 @@ .replace(/<(\/?strong)>/g, '<$1>'); }; + Autocomplete.formatGroup = function (suggestion, index) { + var currentCategory = suggestion.data[groupBy]; + + if (category === currentCategory){ + return ''; + } + + category = currentCategory; + + return '
' + category + '
'; + }; + Autocomplete.prototype = { killerFn: null, @@ -657,17 +670,7 @@ beforeRender = options.beforeRender, html = '', category, - formatGroup = function (suggestion, index) { - var currentCategory = suggestion.data[groupBy]; - - if (category === currentCategory){ - return ''; - } - - category = currentCategory; - - return '
' + category + '
'; - }; + formatGroup = options.formatGroup; if (options.triggerSelectOnValidInput && that.isExactMatch(value)) { that.select(0);