Show errors in the looper in the tooltip

I am using parsley 2.0.0-rc5 and want to display error messages in a tooltip. I use "parsley: field: error", but the event fires before the error is displayed in the error container, and I cannot get the error. Does anyone know how I get an error message for each field?

$.listen('parsley:field:error', function (e) { dataParsleyId = e.$element.attr('data-parsley-id'); errorMsg = 'Error: ' + $('#parsley-id-'+dataParsleyId).text(); e.$element.attr('data-original-title', errorMsg); e.$element.tooltip('show'); }); 
+6
source share
1 answer

Guillaume Potier, the author of parsley, added the ParsleyUI.getErrorsMessages(parsleyFieldInstance) method, which will return an array of message errors. It is available on the main branch on github and will be released in the next stable version.

This works fine for me, and this is my sample code:

 window.Parsley.on('field:error', function (fieldInstance) { fieldInstance.$element.popover({ trigger: 'manual', container: 'body', placement: 'right', content: function () { return fieldInstance.getErrorsMessages().join(';'); } }).popover('show'); }); window.Parsley.on('field:success', function (fieldInstance) { fieldInstance.$element.popover('destroy'); }); 
+14
source

All Articles