diff --git a/src/Callback.php b/src/Callback.php index bfb7a327a8..a54aac96ba 100644 --- a/src/Callback.php +++ b/src/Callback.php @@ -49,8 +49,6 @@ 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 @@ -122,7 +120,7 @@ public function canTrigger(): bool */ public function getJsUrl(string $value = 'ajax'): string { - return $this->getOwner()->jsUrl($this->getUrlArguments($value)); + return $this->getOwner()->jsUrl($this->getUrlArguments($value), true); } /** @@ -131,7 +129,7 @@ public function getJsUrl(string $value = 'ajax'): string */ public function getUrl(string $value = 'callback'): string { - return $this->getOwner()->url($this->getUrlArguments($value)); + return $this->getOwner()->url($this->getUrlArguments($value), true); } /** diff --git a/src/JsReload.php b/src/JsReload.php index 0b82b969e9..7b226a2175 100644 --- a/src/JsReload.php +++ b/src/JsReload.php @@ -55,7 +55,7 @@ public function jsRender(): string $final = (new Jquery($this->view)) ->atkReloadView( [ - 'uri' => $this->view->jsUrl(['__atk_reload' => $this->view->name]), + 'uri' => $this->view->jsUrl(['__atk_reload' => $this->view->name], true), 'uri_options' => !empty($this->args) ? $this->args : null, 'afterSuccess' => $this->afterSuccess ? $this->afterSuccess->jsRender() : null, 'apiConfig' => !empty($this->apiConfig) ? $this->apiConfig : null, diff --git a/src/View.php b/src/View.php index 174036890f..b88caa41b5 100644 --- a/src/View.php +++ b/src/View.php @@ -597,9 +597,9 @@ public function removeAttr($property) * * @return string */ - public function jsUrl($page = []) + public function jsUrl($page = [], bool $includeRunningCallback = false) { - return $this->getApp()->jsUrl($page, false, $this->_getStickyArgs()); + return $this->getApp()->jsUrl($page, false, array_merge($this->_getStickyArgs(), $includeRunningCallback ? $this->getCallbackArguments() : [])); } /** @@ -611,9 +611,9 @@ public function jsUrl($page = []) * * @return string */ - public function url($page = []) + public function url($page = [], bool $includeRunningCallback = false) { - return $this->getApp()->url($page, false, $this->_getStickyArgs()); + return $this->getApp()->url($page, false, array_merge($this->_getStickyArgs(), $includeRunningCallback ? $this->getCallbackArguments() : [])); } /** @@ -630,6 +630,18 @@ protected function _getStickyArgs(): array return $stickyArgs; } + protected function getCallbackArguments(): array + { + $triggers = []; + foreach ($_GET as $k => $get) { + if (str_starts_with($k, Callback::URL_QUERY_TRIGGER_PREFIX)) { + $triggers[$k] = $get; + } + } + + return $triggers; + } + /** * Mark GET argument as sticky. Calling url() on this view or any * sub-views will embedd the value of this GET argument.