Question / Situation
We want to validate a webform (through webform_ajax) which is dynamically loaded with AJAX.
Steps (desired)
- Visitors clicks on link
- Data is loaded in a DIV (jQuery AJAX Load)
- Form is rendered and can be send (with validation and AJAX send)
Problem
When submitting the form the AJAX validation won't trigger and the visitor is send to the corresponding node (next page). How can we setup Drupal to accomplish the desired steps? We use the following Modules and we've tried several techniques, see Tested below.
Technical problem
On a normal node the webform has Drupal.settings, but when loaded with AJAX there are no Drupal.settings for the webform. The Drupal.settings include a Node-ID which is used on the parent wrapper DIV (example: #webform-ajax-wrapper-127). Stripping the ID at the end for global use didn't work.
Main question
How can we solve this problem?
Sub questions (separate or steps to solve this problem)
- What is the best way to include JS after an AJAX load (new content)?
- How can we (re)initiate the Webform/Webform AJAX on the new content?
- How can we add custom/new Webform Drupal.settings?
Tested
- Behaviors:
$('div').ajaxComplete(function(){Drupal.attachBehaviors(DIV);});
- Inserting JS to page
drupal_add_js('sites/all/modules/webform/js/webform.js');
- Inserting an other webform to use the code for the new content.
Modules for function
- jQuery AJAX Load
- Webform
- Webform Ajax
Modules on page
- Panels
- Views
Can you help me in the right direction? What is your experience to accomplish this?