Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Response for autocomplete script is incorrect

Peter van der Doese51f26f86556
diff --git a/wger/exercises/templates/exercise/overview.html b/wger/exercises/templates/exercise/overview.html
index 015c223f5..ebdf02498 100644
--- a/wger/exercises/templates/exercise/overview.html
+++ b/wger/exercises/templates/exercise/overview.html
@@ -17,25 +17,15 @@
$(document).ready(function() {
// Init the autocompleter
- $('#exercise-search').devbridgeAutocomplete({
- showNoSuggestionNotice: true,
+ $('#exercise-search').autocomplete({
serviceUrl: '{% url 'exercise-search' %}',
+ showNoSuggestionNotice: true,
+ dataType: 'json',
+ paramName: 'term',
+ groupBy: 'category',
+ minChars: 3,
onSelect: function (suggestion) {
window.location.href = '/exercise/' + suggestion.data.id + '/view/'
- },
- groupBy: 'category',
- paramName: 'term',
- transformResult: function(response) {
- // why is response not already a JSON object??
- var jsonResponse = $.parseJSON(response);
- return {
- suggestions: $.map(jsonResponse, function(item) {
- return {value: item.value, data: {id: item.id,
- category: item.category,
- image: item.image,
- thumbnail: item.image_thumbnail}};
- })
- };
}
});
});