Example: JavaScript

Same name and namespace in other branches
  1. 8.x-1.x js_example/js_example.module \js_example
  2. 7.x-1.x js_example/js_example.module \js_example
  3. 4.0.x modules/js_example/js_example.module \js_example

Examples using Drupal 8's built-in JavaScript.

We have two examples here.

One 'weights' content and then sorts it by weight. This demonstrates attaching JavaScript through Drupal's render arrays.

The other demonstrates adding an accordion effect to content, through Drupal's theme layer.

Parent topics

File

modules/js_example/js_example.module, line 8

Functions

Title Sort descending File name Summary
js_example_theme modules/js_example/js_example.module Implements hook_theme().

Classes

Title Sort descending File name Summary
JsExampleTest modules/js_example/tests/src/Functional/JsExampleTest.php Functional tests for the js_example module.