From 7e8aa2cafcab99e559b46e35b25e36c1e3ce034b Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Fri, 3 Jan 2025 16:26:31 +0100 Subject: [PATCH] UI/Viewcontrols: 43190, JS using factory (#8782) --- .../Component/ViewControl/Renderer.php | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/components/ILIAS/UI/src/Implementation/Component/ViewControl/Renderer.php b/components/ILIAS/UI/src/Implementation/Component/ViewControl/Renderer.php index a5dcb539bf12..0f4bee03c855 100644 --- a/components/ILIAS/UI/src/Implementation/Component/ViewControl/Renderer.php +++ b/components/ILIAS/UI/src/Implementation/Component/ViewControl/Renderer.php @@ -139,11 +139,16 @@ protected function renderSortation( if ($triggeredSignals) { $internal_signal = $component->getSelectSignal(); $signal = $triggeredSignals[0]->getSignal(); - - $component = $component->withAdditionalOnLoadCode(fn($id) => "$(document).on('$internal_signal', function(event, signalData) { - il.UI.viewcontrol.sortation.onInternalSelect(event, signalData, '$signal', '$id'); - return false; - })"); + $component = $component + ->withAdditionalOnLoadCode( + fn($id) => "il.UI.viewcontrol.sortation.init('$id');" + ) + ->withAdditionalOnLoadCode( + fn($id) => "$(document).on('$internal_signal', function(event, signalData) { + il.UI.viewcontrol.sortation.get('$id').onInternalSelect(event, signalData, '$signal'); + return false; + })" + ); } $this->renderId($component, $tpl, "id", "ID"); @@ -177,7 +182,7 @@ protected function renderPagination( ): string { $range = $this->getPaginationRange($component); - if($component->getNumberOfPages() < 2) { + if ($component->getNumberOfPages() < 2) { return ''; } @@ -187,12 +192,16 @@ protected function renderPagination( if ($triggeredSignals) { $internal_signal = $component->getInternalSignal(); $signal = $triggeredSignals[0]->getSignal(); - $component = $component->withOnLoadCode( - fn($id) => "$(document).on('$internal_signal', function(event, signalData) { - il.UI.viewcontrol.pagination.onInternalSelect(event, signalData, '$signal', '$id'); - return false; - })" - ); + $component = $component + ->withAdditionalOnLoadCode( + fn($id) => "il.UI.viewcontrol.pagination.init('$id');" + ) + ->withAdditionalOnLoadCode( + fn($id) => "$(document).on('$internal_signal', function(event, signalData) { + il.UI.viewcontrol.pagination.get('$id').onInternalSelect(event, signalData, '$signal'); + return false; + })" + ); $id = $this->bindJavaScript($component); $tpl->setVariable('ID', $id); }