function EntityReferenceWidgetTest::sortableUpdate

Same name and namespace in other branches
  1. 11.x core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::sortableUpdate()
  2. 9 core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::sortableUpdate()

Define to provide any necessary callback following layout change.

Parameters

string $item: The HTML selector for the element to be moved.

string $from: The HTML selector for the previous container element.

null|string $to: The HTML selector for the target container.

Overrides SortableTestTrait::sortableUpdate

File

core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php, line 582

Class

EntityReferenceWidgetTest
Tests the Media library entity reference widget.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function sortableUpdate($item, $from, $to = NULL) {
  // See core/modules/media_library/js/media_library.widget.js.
  $script = <<<JS
  (function (\$) {
      var selection = document.querySelectorAll('.js-media-library-selection');
      selection.forEach(function (widget) {
          \$(widget).children().each(function (index, child) {
              \$(child).find('.js-media-library-item-weight').val(index);
          });
      });
  })(jQuery)
  
  JS;
  $this->getSession()
    ->executeScript($script);
}

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