Add auto search on autocomplete select
This commit is contained in:
parent
57338dc0ce
commit
edeece9d7c
|
@ -18,7 +18,7 @@
|
|||
<div class="ui-widget" id="search-widget">
|
||||
<input id="search-bar" placeholder="Search..." type="text" autocorrect="off" autocapitalize="none" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="ui-button ui-widget ui-button-icon-only" id="search">
|
||||
<button type="submit" class="ui-button ui-widget" id="search">
|
||||
<span class="ui-icon ui-icon-search"></span>
|
||||
</button>
|
||||
</form>
|
||||
|
|
|
@ -23,13 +23,18 @@ $(document).ready(() => {
|
|||
url: '/langs/polish/words?like=' + request.term + '&limit=20&offset=0',
|
||||
success: data => response(data)
|
||||
})
|
||||
}
|
||||
},
|
||||
select: (_, ui) => window.location.hash = ui.item.value
|
||||
});
|
||||
|
||||
searchBar.on('focus', e => {
|
||||
setTimeout(() => e.currentTarget.select(), 100);
|
||||
});
|
||||
|
||||
$(window).on('scroll', () => {
|
||||
searchBar.autocomplete('close');
|
||||
});
|
||||
|
||||
$('#search-form').on('submit', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
|
@ -40,18 +45,20 @@ $(document).ready(() => {
|
|||
|
||||
function getWord() {
|
||||
let word = window.location.hash.replace('#', '');
|
||||
|
||||
$.ajax({
|
||||
url: '/langs/polish/words/' + word,
|
||||
|
||||
success: (data) => {
|
||||
$('#ajax-content').html(generateHtml(word, data))
|
||||
window.scrollTo(0, 0);
|
||||
searchBar.select();
|
||||
searchBar.autocomplete('close');
|
||||
},
|
||||
|
||||
error: err => console.error(err)
|
||||
})
|
||||
|
||||
window.scrollTo(0, 0);
|
||||
searchBar.select();
|
||||
searchBar.autocomplete('close');
|
||||
}
|
||||
|
||||
function getCells(forms, tags) {
|
||||
|
|
Loading…
Reference in New Issue