diff --git a/core/misc/ajax.js b/core/misc/ajax.js index fefe9f3031..de7904750a 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -635,7 +635,7 @@ element.type !== 'textarea' && element.type !== 'tel' && element.type !== 'number')) { event.preventDefault(); event.stopPropagation(); - $(ajax.element_settings.element).trigger(ajax.element_settings.event); + $(element).trigger(ajax.element_settings.event); } }; diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml index ccca279b69..6271408417 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml +++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml @@ -30,3 +30,11 @@ ajax_forms_test.lazy_load_form: requirements: _access: 'TRUE' +ajax_forms_test.image_button_form: + path: '/ajax_forms_image_button_form' + defaults: + _title: 'AJAX forms image button test' + _form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestImageButtonForm' + requirements: + _access: 'TRUE' + diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php index 0ad80c9250..06c4b0bb0d 100644 --- a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php +++ b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php @@ -33,6 +33,15 @@ public function checkboxCallback($form, FormStateInterface $form_state) { } /** + * Ajax callback to confirm image button was submitted. + */ + public function imageButtonCallback($form, FormStateInterface $form_state) { + $response = new AjaxResponse(); + $response->addCommand(new HtmlCommand('#ajax_image_button_result', "