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.

CommentFileSizeAuthor
#1 visitor_actions.drupal_forms.1.patch2.04 KBeshta

Comments

eshta’s picture

Assigned: eshta » Unassigned
Status: Active » Needs review
StatusFileSize
new2.04 KB

I'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.

katbailey’s picture

Really helpful snippet from dreditor (it's the closing brace for the ajaxed.eventResponse function definition):

+++ b/js/visitor_actions.js
@@ -234,13 +234,38 @@
+            }

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!

eshta’s picture

Status: Needs review » Fixed

Committed with additional semi-colon for clarity.

  • Commit 9b136fd on 7.x-1.x by eshta:
    Issue #2276303 by eshta: allow subscribing to Drupal AJAX form...
eshta’s picture

For 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.