function JsOnceTestController::onceBcTest

Provides elements for testing jQuery Once BC support.

Return value

array The render array.

1 string reference to 'JsOnceTestController::onceBcTest'
js_once_test.routing.yml in core/modules/system/tests/modules/js_once_test/js_once_test.routing.yml
core/modules/system/tests/modules/js_once_test/js_once_test.routing.yml

File

core/modules/system/tests/modules/js_once_test/src/Controller/JsOnceTestController.php, line 41

Class

JsOnceTestController
Controller for testing the @drupal/once library integration.

Namespace

Drupal\js_once_test\Controller

Code

public function onceBcTest() {
    $output = [
        '#attached' => [
            'library' => [
                'core/jquery.once',
            ],
        ],
    ];
    foreach (range(1, 5) as $item) {
        $output['item' . $item] = [
            '#type' => 'html_tag',
            '#tag' => 'div',
            '#value' => 'Item ' . $item,
            '#attributes' => [
                'data-drupal-item' => $item,
            ],
        ];
    }
    return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.