Skip to content

Commit

Permalink
[FIX] Autocomplete error when no doctrine is available
Browse files Browse the repository at this point in the history
  • Loading branch information
ppfeufer committed Nov 8, 2024
1 parent e1ef391 commit 58cf56d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
36 changes: 23 additions & 13 deletions afat/static/afat/javascript/afat-fatlink-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@ import Autocomplete from '/static/afat/libs/bootstrap5-autocomplete/1.1.25/autoc
$(document).ready(() => {
'use strict';

/**
* Initialize autocomplete dropdown
*
* @param {HTMLElement} element
*/
const autoCompleteDropdown = (element) => {
const autoCompleteDoctrine = new Autocomplete( // eslint-disable-line no-unused-vars
element,
Object.assign(
{},
{
onSelectItem: console.log,
},
{
onRenderItem: (item, label) => {
return `<l-i set="fl" name="${item.value.toLowerCase()}" size="16"></l-i> ${label}`;
const datalistId = element.getAttribute('data-datalist');
const datalist = document.getElementById(datalistId);

if (datalist) {
const autoCompleteDoctrine = new Autocomplete( // eslint-disable-line no-unused-vars
element,
Object.assign(
{},
{
onSelectItem: console.log,
},
}
)
);
{
onRenderItem: (item, label) => {
return `<l-i set="fl" name="${item.value.toLowerCase()}" size="16"></l-i> ${label}`;
},
}
)
);
}
};

autoCompleteDropdown(document.getElementById('id_doctrine_esi'));
Expand Down
2 changes: 1 addition & 1 deletion afat/static/afat/javascript/afat-fatlink-add.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion afat/static/afat/javascript/afat-fatlink-add.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58cf56d

Please sign in to comment.