When adding a goal client-side form action to a Drupal AJAX submitted form, the submit handler is never called in Drupal.visitorActions.form and therefore callbacks are never called. This can be reproduced by using the examples module form submission: https://api.drupal.org/api/examples/ajax_example%21ajax_example.module/f...
The bindEvent is properly called, but the submit handler is never fired when the submit button is pressed.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | visitor_actions.drupal_forms.1.patch | 2.04 KB | eshta |
Comments
Comment #1
eshta commentedI'm attaching a patch that adds a listener into the Drupal ajax eventResponse method. While the documented approach to work before a ajax form submission is to use beforeSubmit - this does not provide access to the event object that is expected by subscribers to actions.
Comment #2
katbailey commentedReally helpful snippet from dreditor (it's the closing brace for the ajaxed.eventResponse function definition):
This will sound totally anal, but there should be a semi-colon here, and this will help clarify that it's not the end of an if or for statement (I got confused and thought that the return; would be executed even if you hadn't found the form id in question.
Otherwise this is great!
Comment #3
eshta commentedCommitted with additional semi-colon for clarity.
Comment #5
eshta commentedFor completeness sake, however, we really should indicate that a server-side form submission is the correct visitor action to use for a Drupal AJAX form. Otherwise, the action is fired for the submission/validation and not just when the form is successfully submitted. Perhaps we need clearer terminology for the types of form submission actions.