Improve state management
This commit is contained in:
parent
4e504997da
commit
ea389f4b1c
|
@ -43,22 +43,28 @@ $(document).ready(() => {
|
||||||
function getWord() {
|
function getWord() {
|
||||||
let word = window.location.hash.replace('#', '');
|
let word = window.location.hash.replace('#', '');
|
||||||
|
|
||||||
$.ajax({
|
if (word) {
|
||||||
url: '/langs/pl/words/' + word,
|
document.title = `Inflective - ${decodeURIComponent(word)}`;
|
||||||
|
|
||||||
success: (data) => {
|
$.ajax({
|
||||||
$('#ajax-content').html(generateHtml(word, data))
|
url: '/langs/pl/words/' + word,
|
||||||
},
|
|
||||||
|
|
||||||
error: err => console.error(err)
|
success: (data) => {
|
||||||
})
|
$('#ajax-content').html(generateHtml(word, data));
|
||||||
|
},
|
||||||
|
|
||||||
window.scrollTo(0, 0);
|
error: err => console.error(err)
|
||||||
searchBar.select();
|
})
|
||||||
searchBar.autocomplete('close');
|
|
||||||
// Sometimes autocomplete opens after close was called
|
window.scrollTo(0, 0);
|
||||||
// A better fix should be made
|
searchBar.select();
|
||||||
setTimeout(() => searchBar.autocomplete('close'), 1000);
|
searchBar.autocomplete('close');
|
||||||
|
// Sometimes autocomplete opens after close was called
|
||||||
|
// A better fix should be made
|
||||||
|
setTimeout(() => searchBar.autocomplete('close'), 1000);
|
||||||
|
} else {
|
||||||
|
$('#ajax-content').html('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCells(forms, tags) {
|
function getCells(forms, tags) {
|
||||||
|
|
Loading…
Reference in New Issue