Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ajax_command_page_reload
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ajax_command_page_reload
Commits
e8c038d4
Commit
e8c038d4
authored
1 year ago
by
Julian Pustkuchen
Committed by
Pedro Pelaez
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve
#3397446
"Attach library with command"
parent
26f11395
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!3
Resolve #3397446 "Attach library with command"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+10
-0
10 additions, 0 deletions
README.md
README.txt
+0
-11
0 additions, 11 deletions
README.txt
src/Ajax/PageReloadCommand.php
+12
-1
12 additions, 1 deletion
src/Ajax/PageReloadCommand.php
with
22 additions
and
12 deletions
README.md
0 → 100644
+
10
−
0
View file @
e8c038d4
# Ajax Command Page Reload
## Usage
See
[
Drupal Core AJAX API
](
https://www.drupal.org/docs/drupal-apis/ajax-api
)
for general documentation.
~~~
$response = new AjaxResponse();
$response->addCommand(new PageReloadCommand());
return $response;
~~~
This diff is collapsed.
Click to expand it.
README.txt
deleted
100644 → 0
+
0
−
11
View file @
26f11395
Ajax Command Page Reload
Usage:
Add the library to the page with something like:
`$form['#attached']['library'][] = "ajax_command_page_reload/ajax_commands";`
Then a callback can send the command:
`$response->addCommand(new PageReloadCommand());`
This diff is collapsed.
Click to expand it.
src/Ajax/PageReloadCommand.php
+
12
−
1
View file @
e8c038d4
...
...
@@ -3,11 +3,13 @@
namespace
Drupal\ajax_command_page_reload\Ajax
;
use
Drupal\Core\Ajax\CommandInterface
;
use
Drupal\Core\Ajax\CommandWithAttachedAssetsInterface
;
use
Drupal\Core\Asset\AttachedAssets
;
/**
* Trigger "window.location.reload()" within the frontend.
*/
class
PageReloadCommand
implements
CommandInterface
{
class
PageReloadCommand
implements
CommandInterface
,
CommandWithAttachedAssetsInterface
{
/**
* {@inheritdoc}
...
...
@@ -18,4 +20,13 @@ class PageReloadCommand implements CommandInterface {
];
}
/**
* {@inheritdoc}
*/
public
function
getAttachedAssets
()
{
$assets
=
new
AttachedAssets
();
$assets
->
setLibraries
([
'ajax_command_page_reload/ajax_commands'
]);
return
$assets
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment