0
我想在每個消息Parsley.js之前添加span元素。此代碼適用於準備好的消息,但不適用於自定義消息。Parsley.js在錯誤消息之前添加跨度
/**
* Add/override error message
*
* @method addMessage
* @param {String} name Message name. Will automatically be binded to validator with same name
* @param {String} message Message
*/
, addMessage: function (key, message, type) {
if ('undefined' !== typeof type && true === type) {
this.messages.type[ key ] = '<span class="del2"></span>' + message;
return;
}
// custom types messages are a bit tricky cuz' nested ;)
if ('type' === key) {
for (var i in message) {
this.messages.type[ i ] = '<span class="del2"></span>' + message[ i ];
}
return;
}
this.messages[ key ] = '<span class="del2"></span>' + message;
}
};