Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
Adds getErrorAnchor to the options object, to fetch the element in wh…
Browse files Browse the repository at this point in the history
…ich the error msg will be inserted before.
  • Loading branch information
Zach Leatherman committed Apr 15, 2014
1 parent 8e3bd4b commit f5a96bd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 : $( '<div>' ).addClass( 'error-msg' ).insertBefore( $el );
return $prev.length ? $prev : $( '<div>' ).addClass( 'error-msg' ).insertBefore( $anchor );
};

/*
Expand Down

0 comments on commit f5a96bd

Please sign in to comment.