我想在每个消息都是Parsley.js之前添加span元素。此代码适用于已准备好的消息,但不适用于自定义消息。
/**
* 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;
}
};
答案 0 :(得分:0)
必须由liError[ liClass ] = message;
liError[ liClass ] = '<span class="del2"></span>' + message;