Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

No need to transform the AJAX response

Peter van der Does7d23b6eb07e4
diff --git a/wger/core/static/js/wger-core.js b/wger/core/static/js/wger-core.js
index 1f54ec540..b5ddd7e70 100644
--- a/wger/core/static/js/wger-core.js
+++ b/wger/core/static/js/wger-core.js
@@ -478,6 +478,9 @@ function wgerInitEditSet() {
$('#exercise-search').devbridgeAutocomplete({
serviceUrl: '/api/v2/exercise/search/?language=' + getCurrentLanguage(),
showNoSuggestionNotice: true,
+ groupBy: 'category',
+ paramName: 'term',
+ minChars: 3,
onSelect: function (suggestion) {
// Add the exercise to the list
addExercise({
@@ -494,25 +497,6 @@ function wgerInitEditSet() {
// Reset the autocompleter
$(this).val('');
return false;
- },
- 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
- }
- };
- })
- };
}
});