From eeda797a81c2c7e278fba2850cb379fcb643c7c2 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 23 Nov 2024 12:20:39 +0530 Subject: [PATCH] Fix JS error --- config/asset_compress.ini | 6 +++--- webroot/js/local.js | 20 ++++---------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/config/asset_compress.ini b/config/asset_compress.ini index 3646c73..c8c32b8 100644 --- a/config/asset_compress.ini +++ b/config/asset_compress.ini @@ -1,15 +1,15 @@ [crudview.css] files[]=https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/css/bootstrap.min.css files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6/dist/flatpickr.min.css -files[]=https://cdn.jsdelivr.net/npm/select2@4.0/dist/css/select2.min.css +files[]=https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css files[]=https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3/dist/select2-bootstrap-5-theme.min.css files[]=plugin:CrudView:css/local.css [crudview_head.js] files[]=https://cdn.jsdelivr.net/npm/jquery@3.7/dist/jquery.min.js -files[]=https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/js/bootstrap.min.js +files[]=https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/js/bootstrap.bundle.min.js files[]=https://cdn.jsdelivr.net/npm/flatpickr@4.6 -files[]=https://cdn.jsdelivr.net/npm/select2@4.0 +files[]=https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js files[]=https://cdn.jsdelivr.net/npm/jquery.dirtyforms@2.0/jquery.dirtyforms.min.js [crudview.js] diff --git a/webroot/js/local.js b/webroot/js/local.js index 319c379..94304bc 100644 --- a/webroot/js/local.js +++ b/webroot/js/local.js @@ -20,7 +20,7 @@ var CrudView = { select2: function (selector) { $(selector).each(function () { var $this = $(this), - config = {theme: 'bootstrap4'}; + config = {theme: 'bootstrap-5'}; if (!$this.prop('multiple') && $this.find('option:first').val() === '') { config.allowClear = true; @@ -36,7 +36,7 @@ var CrudView = { var $ele = $(ele); $ele.select2({ - theme: 'bootstrap4', + theme: 'bootstrap-5', minimumInputLength: 1, ajax: { delay: 250, @@ -82,20 +82,9 @@ var CrudView = { $('form[data-dirty-check=1]').dirtyForms(); }, - dropdown: function () { - $('.dropdown-toggle').dropdown(); - - // recommended hack to get dropdowns correctly work inside responsive table - $('.table-responsive').on('show.bs.dropdown', function () { - $('.table-responsive').css( "overflow", "inherit" ); - }); - $('.table-responsive').on('hide.bs.dropdown', function () { - $('.table-responsive').css( "overflow", "auto" ); - }) - }, - tooltip: function () { - $('[data-toggle="tooltip"]').tooltip(); + const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') + const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)); }, initialize: function () { @@ -104,7 +93,6 @@ var CrudView = { this.select2('select[multiple]:not(.no-select2), select.select2'); this.autocomplete('input.autocomplete, select.autocomplete'); this.dirtyForms(); - this.dropdown(); this.tooltip(); } };