Last active
January 9, 2017 15:42
-
-
Save merqlove/27351c47a58f7a09ecbe33aac8363545 to your computer and use it in GitHub Desktop.
Autocomplete Address with Semantic UI
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Autocomplete address With Semantic UI</title> | |
<link rel="stylesheet" href="semantic/dist/semantic.css"> | |
</head> | |
<body> | |
<div class="ui very padded text container"> | |
<form class="ui form" id="form"> | |
<h1>Search for address</h1> | |
<div class="ui search focus"> | |
<div class="ui icon input"> | |
<input class="prompt" type="text" placeholder="Street..." autocomplete="off"> | |
<i class="search icon"></i> | |
</div> | |
<div class="results"></div> | |
</div> | |
</form> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | |
<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script> | |
<script src="semantic/dist/semantic.js"></script> | |
<script type="text/javascript"> | |
$( document ).ready(function() { | |
$('.ui.search').search({ | |
apiSettings: { | |
responseAsync: function(settings, callback) { | |
var query = settings.urlData.query; | |
ymaps.suggest(query).then(function (items) { | |
callback({results: items}); | |
}); | |
}, | |
stateContext: 'input' | |
}, | |
searchFullText: false, | |
minCharacters : 3, | |
fields: {title: 'displayName', category: 'type'} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment