Parsley.js错误消息 [英] Parsley.js error message

查看:384
本文介绍了Parsley.js错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是来自 http://parsleyjs.org/ 的parsley.js。想从回调函数(onFieldError)获取错误消息,并将值放在twitter引导弹出框中。为了做到这一点,我需要将它放在popover的data-content属性中,而不是div。任何人都可以告诉我如何做到这一点或解决这个问题。

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.

推荐答案

你看看parsley.js源文件,你会看到在文件的底部有一个错误对象配置,允许你控制你想要的位置放你的错误消息。让我们看看它:

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 是将接收 parsley-success parsley-error 类。
errors.container 是dom元素,其中将添加错误元素 - > 基本上,它应该在这里你的popover dom元素
errors.errorsWrapper errors.errorElem 将允许您自定义错误模板ul和lis)

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)

希望能帮助你

最好

这篇关于Parsley.js错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆