0

I have an Webform that uses Webform Ajax modules, Steps module and few others.

I would like to execute some custom JavaScript code after the WebForm has been validted and submited.

I know I could execute custom PHP code by modyfing function _webform_ajax_callback_completed($form, $form_state) {...} inside of webform_ajax.module:

elseif ($form['#node']->webform['webform_ajax'] == WEBFORM_AJAX_CONFIRM){
...
//my custom code
...

But I don't want to mess with this module's code. And I want to execute JavaScript not PHP code.

Is there an way to do so, e.g. via some hook? Or maybe I can detect that form has been submited in JavaScript?

1

Okay, try this. After the ajax request is completed on "#myform", it runs the function.

$("#myform").bind('ajax:complete', function() {

     // tasks to do 


});

Source | API Documentation

  • Please don't post code-only answers. While this might solve the problem, it doesn't explain why or how it solve the problem. – Shawn Conn Dec 1 '16 at 20:43
  • Okay, updated answer – Chris Happy Dec 1 '16 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.