diff --git a/demos/interactive/modal.php b/demos/interactive/modal.php index efb1f5f0df..2bc6ebd1b7 100644 --- a/demos/interactive/modal.php +++ b/demos/interactive/modal.php @@ -210,16 +210,6 @@ $stepModal->js(true)->modal('refresh'); }); -// Bind next action to modal next button. -$nextAction->on('click', $stepModal->js()->atkReloadView( - ['uri' => $stepModal->cb->getJsUrl(), 'uri_options' => ['move' => 'next']] -)); - -// Bin prev action to modal previous button. -$prevAction->on('click', $stepModal->js()->atkReloadView( - ['uri' => $stepModal->cb->getJsUrl(), 'uri_options' => ['move' => 'prev']] -)); - // Bind display modal to page display button. $menuBar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']); $button = \Atk4\Ui\Button::addTo($menuBar)->set('Multi Step Modal'); diff --git a/src/Callback.php b/src/Callback.php index 75d9bf478e..d34c6bb857 100644 --- a/src/Callback.php +++ b/src/Callback.php @@ -54,6 +54,8 @@ protected function init(): void public function setUrlTrigger(string $trigger = null) { $this->urlTrigger = $trigger ?: $this->name; + + // $this->getOwner()->stickyGet(self::URL_QUERY_TRIGGER_PREFIX . $this->urlTrigger); } public function getUrlTrigger(): string diff --git a/src/JsReload.php b/src/JsReload.php index 0b82b969e9..fe390a264f 100644 --- a/src/JsReload.php +++ b/src/JsReload.php @@ -49,9 +49,28 @@ public function __construct($view, $args = [], $afterSuccess = null, $apiConfig $this->apiConfig = $apiConfig; $this->includeStorage = $includeStorage; } - + + public function dumpRenderTree(View $view, bool $rec = false): void + { + if ($view->issetOwner() && $view->getOwner() instanceof View) { + $this->dumpRenderTree($view->getOwner(), true); + } + + echo get_class($view); + + echo "\n" . (!$rec ? "\n\n" : ''); + } public function jsRender(): string { + ini_set('output_buffering', (string) (1024 * 1024)); + ob_start(); + $this->dumpRenderTree($this->view); + // test URL: /demos/interactive/modal.php?__atk_m=atk_layout_maestro_modal_5&__atk_cbtarget=atk_layout_maestro_modal_5_view_callbacklater&__atk_cb_atk_layout_maestro_modal_5_view_callbacklater=ajax&__atk_json=1 + echo 'actual: '; var_dump($this->view->jsUrl(['__atk_reload' => $this->view->name])); + echo 'expected: string(166) "modal.php?__atk_m=atk_layout_maestro_modal_5&__atk_cb_atk_layout_maestro_modal_5_view_callbacklater=ajax&__atk_reload=atk_layout_maestro_modal_5_view_demos_viewtester"' . "\n"; + ob_end_flush(); + exit; + $final = (new Jquery($this->view)) ->atkReloadView( [ diff --git a/src/View.php b/src/View.php index a1a244205a..e66bcf4f1d 100644 --- a/src/View.php +++ b/src/View.php @@ -619,6 +619,7 @@ public function url($page = []) protected function getRunningCallbackArgs(bool $isTerminated, array $page): array { $args = []; + foreach ($this->elements as $v) { if ($v instanceof Callback) { // @phpstan-ignore-line if (($page[Callback::URL_QUERY_TARGET] ?? null) === $v->getUrlTrigger()) { @@ -631,8 +632,13 @@ protected function getRunningCallbackArgs(bool $isTerminated, array $page): arra } } + $parentRenderView = null; if ($this->issetOwner() && $this->getOwner() instanceof self) { - $args = array_merge($this->getOwner()->getRunningCallbackArgs($isTerminated, $page), $args); + $parentRenderView = $this->getOwner(); + } // else + + if ($parentRenderView !== null) { + $args = array_merge($parentRenderView->getRunningCallbackArgs($isTerminated, $page), $args); } return $args;