fix: [genericElement:index_table] Better support of nested dropdown if it has been added after page load

pull/73/head
Sami Mokaddem 2021-10-20 15:41:11 +02:00
parent 7940920f3d
commit 8686aa87a6
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 11 additions and 3 deletions

View File

@ -65,6 +65,7 @@ echo $availableColumnsHtml;
}
$(document).ready(function() {
addSupportOfNestedDropdown();
const $form = $('form.visible-column-form')
const $checkboxes = $form.find('input').not(':checked')
const $dropdownMenu = $form.closest('.dropdown')

View File

@ -243,8 +243,13 @@ function overloadBSDropdown() {
return _orginal.call(this);
}
}($bs.Dropdown.prototype.toggle);
})(bootstrap);
}
document.querySelectorAll('.dropdown').forEach(function (dd) {
function addSupportOfNestedDropdown() {
const CLASS_NAME_HAS_CHILD = 'has-child-dropdown-show';
document.querySelectorAll('.dropdown').forEach(function (dd) {
if (dd.getAttribute('data-listener-registered') === null) { // Only add listener once
dd.addEventListener('hide.bs.dropdown', function (e) {
if (this.classList.contains(CLASS_NAME_HAS_CHILD)) {
this.classList.remove(CLASS_NAME_HAS_CHILD);
@ -261,8 +266,9 @@ function overloadBSDropdown() {
}
e.stopPropagation(); // do not need pop in multi level mode
});
});
})(bootstrap);
dd.setAttribute('data-listener-registered', 1)
}
});
}
var UI
@ -271,6 +277,7 @@ $(document).ready(() => {
UI = new UIFactory()
}
overloadBSDropdown();
addSupportOfNestedDropdown();
const debouncedGlobalSearch = debounce(performGlobalSearch, 400)
$('#globalSearch')