Created
August 29, 2018 12:18
-
-
Save adw0rd/892c11a15f634492e61ab85e460ddcbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#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