简体   繁体   English

如何设置Parsley.js全局配置

[英]How to set Parsley.js global config

Most of the docs I found is not helping me as it seems to be outdated or I am doing something wrong. 我发现的大多数文档都没有帮助我,因为它似乎已经过时或我做错了什么。

$.fn.parsley.defaults = {} // not working
window.parsley.defaults = {} // not working
window.ParsleyConfig = {} // not working

Basically what I am trying to do is, I want the below given options to set globally and not repeat the same code for each form in my application: 基本上,我想做的是,我希望以下给定的选项能够全局设置,而不要对应用程序中的每种表单重复相同的代码:

$('#sign-in-form').parsley({
    successClass: "has-success",
    errorClass: "has-error",
    classHandler: function (el) {
      return el.$element.closest(".form-group");
    },
    errorsWrapper: "<span class='help-block'></span>",
    errorTemplate: "<span></span>"
  });

The above code is working (along with bootstrap) 上面的代码正在工作(以及引导程序)

我希望对文档进行改进以回答您的问题。

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

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