No need to transform the AJAX response

This commit is contained in:
Peter van der Does
2016-09-03 16:05:24 -04:00
parent e51f26f865
commit 7d23b6eb07

View File

@@ -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
}
};
})
};
}
});