ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
with_additional_on_load_code.php File Reference

Go to the source code of this file.

Functions

 with_additional_on_load_code ()
 Example showing how JS-Code can be attached to images. More...
 

Function Documentation

◆ with_additional_on_load_code()

with_additional_on_load_code ( )

Example showing how JS-Code can be attached to images.

In this example, an alert is poping up a soon as the image is clicked.

Definition at line 7 of file with_additional_on_load_code.php.

References $DIC, and Vendor\Package\$f.

8 {
9  //Loading factories
10  global $DIC;
11  $f = $DIC->ui()->factory();
12  $renderer = $DIC->ui()->renderer();
13 
14  //Genarating and rendering the image and modal
15  $image = $f->image()->standard(
16  "src/UI/examples/Image/HeaderIconLarge.svg",
17  "Thumbnail Example"
18  )->withAction("#")
19  ->withAdditionalOnLoadCode(function ($id) {
20  return "$('#$id').click(function(e) { e.preventDefault(); alert('Image Onload Code')});";
21  });
22 
23  $html = $renderer->render($image);
24 
25  return $html;
26 }
$DIC
Definition: xapitoken.php:46