Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adw0rd/892c11a15f634492e61ab85e460ddcbe to your computer and use it in GitHub Desktop.
Save adw0rd/892c11a15f634492e61ab85e460ddcbe to your computer and use it in GitHub Desktop.
$("#address").suggestions({
token: "5ef98f5781a106962077fb18109095f9f11ebac1",
type: "ADDRESS",
count: 10,
onSuggestionsFetch: function (suggestions) {
var instance = $(this).data('suggestions');
var data = {
"locations": [{"street_type_full": "метро"}],
"restrict_value": false,
"query": instance.currentValue,
"count": instance.options.count
}
var options = instance.getAjaxParams('suggest', {data: JSON.stringify(data)});
options.async = false;
var responseJSON = $.ajax(options).responseJSON;
if (responseJSON && responseJSON.suggestions) {
suggestions = responseJSON.suggestions.concat(suggestions);
}
return suggestions.slice(0, instance.options.count);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment