Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
clientside_validation
Commits
905fbddc
Commit
905fbddc
authored
Oct 07, 2013
by
Jelle
Browse files
Fix closure when changing ajax behaviors
parent
d48555ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
18 deletions
+21
-18
clientside_validation.js
clientside_validation.js
+21
-18
No files found.
clientside_validation.js
View file @
905fbddc
...
...
@@ -1352,28 +1352,31 @@
Drupal
.
behaviors
.
ZZZClientsideValidation
=
{
attach
:
function
()
{
function
changeAjax
(
ajax_el
)
{
var
origBeforeSubmit
=
Drupal
.
ajax
[
ajax_el
].
options
.
beforeSubmit
;
Drupal
.
ajax
[
ajax_el
].
options
.
beforeSubmit
=
function
(
form_values
,
element
,
options
)
{
var
ret
=
origBeforeSubmit
(
form_values
,
element
,
options
);
// If this function didn't return anything, just set the return value to true.
// If it did return something, allow it to prevent submit if necessary.
if
(
typeof
ret
===
'
undefined
'
)
{
ret
=
true
;
}
var
id
=
element
.
is
(
'
form
'
)
?
element
.
attr
(
'
id
'
)
:
element
.
closest
(
'
form
'
).
attr
(
'
id
'
);
if
(
id
&&
Drupal
.
myClientsideValidation
.
validators
[
id
])
{
Drupal
.
myClientsideValidation
.
validators
[
id
].
onsubmit
=
false
;
ret
=
ret
&&
Drupal
.
myClientsideValidation
.
validators
[
id
].
form
();
if
(
!
ret
)
{
Drupal
.
ajax
[
ajax_el
].
ajaxing
=
false
;
}
}
return
ret
;
};
}
// 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
origBeforeSubmit
=
Drupal
.
ajax
[
ajax_el
].
options
.
beforeSubmit
;
Drupal
.
ajax
[
ajax_el
].
options
.
beforeSubmit
=
function
(
form_values
,
element
,
options
)
{
var
ret
=
origBeforeSubmit
(
form_values
,
element
,
options
);
// If this function didn't return anything, just set the return value to true.
// If it did return something, allow it to prevent submit if necessary.
if
(
typeof
ret
===
'
undefined
'
)
{
ret
=
true
;
}
var
id
=
element
.
is
(
'
form
'
)
?
element
.
attr
(
'
id
'
)
:
element
.
closest
(
'
form
'
).
attr
(
'
id
'
);
if
(
id
&&
Drupal
.
myClientsideValidation
.
validators
[
id
])
{
Drupal
.
myClientsideValidation
.
validators
[
id
].
onsubmit
=
false
;
ret
=
ret
&&
Drupal
.
myClientsideValidation
.
validators
[
id
].
form
();
if
(
!
ret
)
{
Drupal
.
ajax
[
ajax_el
].
ajaxing
=
false
;
}
}
return
ret
;
};
changeAjax
(
ajax_el
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment