From f5a96bd3669570c3320ee23c344bebe7eb925c6c Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 15 Apr 2014 13:19:24 -0500 Subject: [PATCH] Adds getErrorAnchor to the options object, to fetch the element in which the error msg will be inserted before. --- src/validator.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/validator.js b/src/validator.js index f281010..56b0f2c 100644 --- a/src/validator.js +++ b/src/validator.js @@ -88,10 +88,11 @@ }; Validator.prototype.getErrorMessageElement = function() { - var $el = this.opts.$applyElement, - $prev = $el.prev( '.error-msg' ); + var callback = this.opts.getErrorAnchor, + $anchor = callback ? callback.call( this ) : this.opts.$applyElement, + $prev = $anchor.prev( '.error-msg' ); - return $prev.length ? $prev : $( '
' ).addClass( 'error-msg' ).insertBefore( $el ); + return $prev.length ? $prev : $( '
' ).addClass( 'error-msg' ).insertBefore( $anchor ); }; /*