ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
show_popover_with_async_loaded_content.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
18 {
19  global $DIC;
20  $factory = $DIC->ui()->factory();
21  $renderer = $DIC->ui()->renderer();
22  $refinery = $DIC->refinery();
23  $request_wrapper = $DIC->http()->wrapper()->query();
24 
25  if (
26  $request_wrapper->has('renderPopoverAsync') &&
27  $request_wrapper->retrieve('renderPopoverAsync', $refinery->kindlyTo()->bool())
28  ) {
29  // This is the ajax request to load the content of the popover. During the ajax request,
30  // a loading spinner is presented to the user. Check the code below on how to construct the popover,
31  // e.g. using Popover::withAsyncContentUrl().
32  $content = $factory->legacy('This text is rendered async');
33  echo $renderer->render($content);
34  exit();
35  }
36 
37  $async_url = $_SERVER['REQUEST_URI'] . '&renderPopoverAsync=1';
38  $popover = $factory->popover()->standard($factory->legacy(''))
39  ->withTitle('Popover')
40  ->withAsyncContentUrl($async_url);
41  $button = $factory->button()->standard('Show Popover', '#')
42  ->withOnClick($popover->getShowSignal());
43 
44  return $renderer->render([$popover, $button]);
45 }
$renderer
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
global $DIC
Definition: shib_login.php:25
show_popover_with_async_loaded_content()
description: > Example for rendering a standard popover with asynchronous loaded content...