From 00072a9bc340c61bf1ae5c8c1f3775a57bcbe577 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 3 Feb 2022 18:22:19 +0300 Subject: [PATCH] fix table limit --- .../resources/js/theme/modal.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/addons/default/visiosoft/defaultadmin-theme/resources/js/theme/modal.js b/addons/default/visiosoft/defaultadmin-theme/resources/js/theme/modal.js index 4bfb28a12..44123df75 100644 --- a/addons/default/visiosoft/defaultadmin-theme/resources/js/theme/modal.js +++ b/addons/default/visiosoft/defaultadmin-theme/resources/js/theme/modal.js @@ -5,7 +5,7 @@ let initModal = function () { let loading = ''; // Loading state - modal.on('loading', function() { + modal.on('loading', function () { $(this).find('.modal-content').append(loading); }); @@ -36,6 +36,25 @@ let initModal = function () { }); }); + // Remove onchange event in ajax select field + if ($('.table--ajax').find('.table-limit').length > 0) { + $('.table--ajax').find('.table-limit').removeAttr("onchange"); + } + + // Handle ajax select in modals. + $('.table--ajax .table-limit').on('change', function (e) { + + e.preventDefault(); + + let wrapper = $(this).closest('.modal-content'); + + wrapper.append(loading); + + $.get($(this).val(), function (html) { + wrapper.html(html); + }); + }); + // Handle ajax forms in modals. modal.on('submit', 'form.ajax', function (e) { @@ -79,7 +98,7 @@ $(document).ajaxComplete(function () { $(document).on('show.bs.modal', '.modal', function () { let zIndex = 1040 + (10 * $('.modal:visible').length); $(this).css('z-index', zIndex); - setTimeout(function() { + setTimeout(function () { $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack'); }, 0); });