Component

Button with ajax-loading state

This component specifically themes ajax-loading states of Drupal form buttons.

 

Better classes

Every button that can trigger ajax-behaviour will receive an extra class:

.ajax-button {}

 

If the form can't use Ajax, but you would like to mimic it using Ajax, you could fake the behaviour with Fake slow submitting form component.

This component relies on the Improved ajax progress indicator component.

 

Creating an ajax-button in the backend

$form['actions']['submit'] = [
  '#type' => 'submit',
  '#value' => $this->t('Trigger ajax'),
  '#ajax' => [
    'callback' => '::ajaxSubmit',
  ],
];


public function ajaxSubmit(array &$form, FormStateInterface $form_state) {
  // Do some ajax hanlding here
}

 

ajax-button
Drupal Core
Using Sass
Responsive
Accessible
CSS
Flat design
2 downloads
horizontal beam No open issue

comments

No comments yet