简体   繁体   English

Parsley.js错误消息

[英]Parsley.js error message

I am using parsley.js from http://parsleyjs.org/ . 我在http://parsleyjs.org/上使用parsley.js。 Wanted to get the error message from the call back function (onFieldError) and place the value inside a twitter bootstrap popover. 想要从回调函数(onFieldError)获取错误消息,并将值放在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. 为了做到这一点,我需要将它放在popover的data-content属性中,而不是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. 这些是唯一可用的参数。

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. 如果查看parsley.js源文件,您将看到文件底部有一个errors对象配置,允许您控制要放置错误消息的位置。 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.classHander是接收parsley-successparsley-error类的dom元素。 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) errors.container是将附加错误元素的dom元素 - > 基本上,它应该在这里你的 errors.errorsWrapper dom元素 errors.errorsWrappererrors.errorElem将允许你更深入地定制错误模板(默认情况下,ul和lis)

Hope that would help you 希望能帮到你

Best 最好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM