You are here

public static function ParagraphsFeatures::addMoreAjax in Paragraphs Features 2.x

Same name and namespace in other branches
  1. 8 src/ParagraphsFeatures.php \Drupal\paragraphs_features\ParagraphsFeatures::addMoreAjax()

Adds a scroll event to the ajax response.

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

Return value

\Drupal\Core\Ajax\AjaxResponse The ajax response with the paragraph to add.

File

src/ParagraphsFeatures.php, line 98

Class

ParagraphsFeatures
Paragraphs features class.

Namespace

Drupal\paragraphs_features

Code

public static function addMoreAjax(array $form, FormStateInterface $form_state) {
  $element = ParagraphsWidget::addMoreAjax($form, $form_state);
  $response = new AjaxResponse();
  $response
    ->addCommand(new InsertCommand(NULL, $element));
  $response
    ->addCommand(new ScrollToElementCommand($element[$element['#max_delta']]['#attributes']['data-drupal-selector'], $element['#attributes']['data-drupal-selector']));
  return $response;
}