Parsley.js error message

非 Y 不嫁゛ 提交于 2019-12-06 08:57:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!