From: Vincent Vanwaelscappel Date: Tue, 9 Sep 2025 12:26:11 +0000 (+0200) Subject: wait #7713 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=012f645eacb1cb5edd1a19f3c51d925c5c456bd9;p=cubist_cms-back.git wait #7713 @2 --- diff --git a/src/public/bunchmultiple/bunchmultiple.js b/src/public/bunchmultiple/bunchmultiple.js index e0bccd0..28221b4 100644 --- a/src/public/bunchmultiple/bunchmultiple.js +++ b/src/public/bunchmultiple/bunchmultiple.js @@ -6,6 +6,7 @@ JQbunchmultiple.prototype = { init: function () { + this.addItemTriggerTimeout; this.inited = false; var $this = this; this.id = $(this.element).attr('id'); @@ -65,6 +66,7 @@ }, 10); } else { item.removeClass('collapsed'); + $(document).trigger('cubist.bunchmultiple.openitem'); } return false; }); @@ -258,7 +260,7 @@ }, initItem: function (values) { - + clearTimeout(this.addItemTriggerTimeout); var $this = this; var collapsed = true; var isNew = false; @@ -304,11 +306,11 @@ $(this).attr('data-bmid', $this.id); }); - setTimeout(function () { + this.addItemTriggerTimeout = setTimeout(function () { $this.setValues(item, values, false); $(document).trigger('cubist.bunchmultiple.added'); $($this).trigger('change'); - }, 10); + }, 100); }, setValues(item, values) { diff --git a/src/resources/views/fields/select2_from_array.blade.php b/src/resources/views/fields/select2_from_array.blade.php index d878567..6ffdc5e 100644 --- a/src/resources/views/fields/select2_from_array.blade.php +++ b/src/resources/views/fields/select2_from_array.blade.php @@ -112,6 +112,9 @@ if($ajax){ $(document).on('cubist.bunchmultiple.added', function () { initUntriggeredSelectFromArray($); }); + $(document).on('cubist.bunchmultiple.openitem', function () { + initUntriggeredSelectFromArray($); + }); initUntriggeredSelectFromArray($); $(document).on('change', '.select2_from_array', function () { @@ -127,9 +130,11 @@ if($ajax){ } function initUntriggeredSelectFromArray($) { + let j = 0; + // trigger select2 for each untriggered select2 box - $('.select2_from_array:not(.select2-hidden-accessible)').each(function (i, obj) { - if ($(obj).closest('.item.sample').length > 0) { + $('.select2_from_array:not(.select2-hidden-accessible):visible:not(.init)').each(function (i, obj) { + if ($(obj).closest('.item.sample,.item.collapsed').length > 0) { return; } var options = { @@ -149,7 +154,11 @@ if($ajax){ } } $(obj).addClass('init').select2(options); + j++; }); + if (j > 0) { + console.log('initUntriggeredSelectFromArray', j); + } showSelectedValue(); }