Commit 271aed03 authored by jelles's avatar jelles
Browse files

Issue #2056219 by inventlogic: General problem with drupal AJAX requests...

Issue #2056219 by inventlogic: General problem with drupal AJAX requests prevented by clientside validation.
parent c067999a
......@@ -293,6 +293,17 @@ function clientside_validation_settings_form($form, $form_state, $cvs_formid = N
'#default_value' => $settings['validate_options']['validate_onkeyup'],
);
$form['validate_options']['validate_before_ajax'] = array(
'#type' => 'radios',
'#options' => array(
'1' => t('Yes'),
'0' => t('No'),
),
'#title' => t('Validate before AJAX calls'),
'#description' => t('Validate elements before ajax calls. Use with caution, this behavior has been known to !cause_issues.', l(t('cause issues'), 'https://drupal.org/project/issues/clientside_validation?text=4bf5b2d&status=All')),
'#default_value' => $settings['validate_options']['validate_before_ajax'],
);
$form['validate_options']['show_messages'] = array(
'#type' => 'radios',
'#options' => array(
......
......@@ -1384,7 +1384,13 @@
// Set validation for ctools modal forms
for (var ajax_el in Drupal.ajax) {
if (typeof Drupal.ajax[ajax_el] !== 'undefined') {
if (!jQuery(Drupal.ajax[ajax_el].element).hasClass('cancel')) {
var $ajax_el = jQuery(Drupal.ajax[ajax_el].element);
var ajax_form = $ajax_el.is('form') ? $ajax_el.attr('id') : $ajax_el.closest('form').attr('id');
var change_ajax = true;
if (typeof (Drupal.myClientsideValidation.forms[ajax_form] !== 'undefined')) {
change_ajax = Boolean(parseInt(Drupal.myClientsideValidation.forms[ajax_form].general.validateBeforeAjax, 10));
}
if (!$ajax_el.hasClass('cancel') && change_ajax) {
changeAjax(ajax_el);
}
}
......
......@@ -452,6 +452,7 @@ function _clientside_validation_add_general_settings(&$settings, $form) {
"validateOnBlur" => $definedsettings['validate_options']['validate_onblur'],
"validateOnBlurAlways" => $definedsettings['validate_options']['validate_onblur_always'],
"validateOnKeyUp" => $definedsettings['validate_options']['validate_onkeyup'],
"validateBeforeAjax" => $definedsettings['validate_options']['validate_before_ajax'],
"validateOnSubmit" => $definedsettings['validate_options']['validate_onsubmit'],
"showMessages" => $definedsettings['validate_options']['show_messages'],
"errorElement" => $definedsettings['error']['error_element'],
......@@ -1492,6 +1493,7 @@ function clientside_validation_settings_load($cvs_type = NULL, $cvs_formid = NUL
'validate_onblur' => 1,
'validate_onblur_always' => 0,
'validate_onkeyup' => 1,
'validate_before_ajax' => 0,
'show_messages' => 0,
'captcha' => 1,
),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment