Skip to content

Commit 2183af2

Browse files
committed
Merge pull request posabsolute#626 from hailwood/promptAt-patch
Added ability to adjust what element a fields prompt is shown on (useful...
2 parents 47df304 + 4f1bda5 commit 2183af2

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

js/jquery.validationEngine.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,18 @@
339339
errorFound |= methods._validateField(field, options);
340340
if (errorFound && first_err==null)
341341
if (field.is(":hidden") && options.prettySelect)
342-
first_err = field = form.find("#" + options.usePrefix + methods._jqSelector(field.attr('id')) + options.useSuffix);
343-
else
344-
first_err=field;
342+
first_err = field = form.find("#" + options.usePrefix + methods._jqSelector(field.attr('id')) + options.useSuffix);
343+
else {
344+
345+
//Check if we need to adjust what element to show the prompt on
346+
//and and such scroll to instead
347+
if(field.data('jqv-prompt-at') instanceof jQuery ){
348+
field = field.data('jqv-prompt-at');
349+
} else if(field.data('jqv-prompt-at')) {
350+
field = $(field.data('jqv-prompt-at'));
351+
}
352+
first_err=field;
353+
}
345354
if (options.doNotShowAllErrosOnSubmit)
346355
return false;
347356
names.push(field.attr('name'));
@@ -1507,6 +1516,13 @@
15071516
* @param {Map} options user options
15081517
*/
15091518
_showPrompt: function(field, promptText, type, ajaxed, options, ajaxform) {
1519+
//Check if we need to adjust what element to show the prompt on
1520+
if(field.data('jqv-prompt-at') instanceof jQuery ){
1521+
field = field.data('jqv-prompt-at');
1522+
} else if(field.data('jqv-prompt-at')) {
1523+
field = $(field.data('jqv-prompt-at'));
1524+
}
1525+
15101526
var prompt = methods._getPrompt(field);
15111527
// The ajax submit errors are not see has an error in the form,
15121528
// When the form errors are returned, the engine see 2 bubbles, but those are ebing closed by the engine at the same time

0 commit comments

Comments
 (0)