问题
I am using parsley.js from http://parsleyjs.org/. Wanted to get the error message from the call back function (onFieldError) and place the value inside a twitter bootstrap popover. In order to do so, I'll need to place it inside the data-content attribute of the popover instead of a div. Can any one tell me how to do this or fix this.
onFieldError: function ( elem, constraints, ParsleyField ) {}
These are the only parameters that are available.
回答1:
If you look in parsley.js source file, you'll see that there is an errors
object config at the bottom of the file that allows you to have control over where you want to put your error messages. Let take a look at it:
// specify where parsley error-success classes are set
errors: {
classHandler: function ( elem, isRadioOrCheckbox ) {}
, container: function ( elem, isRadioOrCheckbox ) {}
, errorsWrapper: '<ul></ul>'
, errorElem: '<li></li>'
}
errors.classHander
is the dom element that would receive parsley-success
and parsley-error
classes.
errors.container
is the dom element where would be appended the error element -> basically, it should be here your popover dom element
errors.errorsWrapper
and errors.errorElem
would allow you to customize deeper the error template (by default, ul and lis)
Hope that would help you
Best
来源:https://stackoverflow.com/questions/16913595/parsley-js-error-message