posabsolute/jQuery-Validation-Engine — Issue #209: suggested patch for better positioning
Author: sharkey3
Created: 2011-11-17 21:04:52+00:00
State: open

This adds a relative positioning option which is very similar to isOverflown, except that it is easy to use. No extra divs are required from the user because it adds its own relative div, and then positions absolutely to that.

Just add "relative:true" to your options, and be happy!

```
--- javascript/jquery/formValidator/js/jquery.validationEngine.js	(revision 49713)
+++ javascript/jquery/formValidator/js/jquery.validationEngine.js	(working copy)
@@ -1163,12 +1163,17 @@
}
}

- //Cedric: Needed if a container is in position:relative
- // insert prompt in the form or in the overflown container?
- if (options.isOverflown)
-	field.before(prompt);
- else
- $("body").append(prompt);
+	if (options.relative) {
+	var outer = $('

').css('position','relative').append(prompt.css('position','absolute'));
+	field.before(outer);
+	} else {
+	//Cedric: Needed if a container is in position:relative
+	// insert prompt in the form or in the overflown container?
+	if (options.isOverflown)
+	field.before(prompt);
+	else
+	$("body").append(prompt);
+	}

var pos = methods._calculatePosition(field, prompt, options);
prompt.css({
@@ -1275,7 +1280,7 @@
var fieldWidth = field.width();
var promptHeight = promptElmt.height();

- var overflow = options.isOverflown;
+ var overflow = options.isOverflown || options.relative;
if (overflow) {
// is the form contained in an overflown container?
promptTopPosition = promptleftPosition = 0;
@@ -1410,6 +1415,8 @@
// Stops form from submitting and execute function assiciated with it
onValidationComplete: false,

+	// relative positioning
+	relative: false,
// Used when the form is displayed within a scrolling DIV
isOverflown: false,
overflownDIV: "",
```