Skip to content

Instantly share code, notes, and snippets.

@dennysfredericci
Created July 2, 2012 03:56
Show Gist options
  • Save dennysfredericci/3030983 to your computer and use it in GitHub Desktop.
Save dennysfredericci/3030983 to your computer and use it in GitHub Desktop.
An easy way to use JQuery Validation with Twitter Bootstrap Popover
$('form').validate(
{
rules: {
numero: {
required: true
},
descricao: {
minlength: 3,
email: true,
required: true
}
},
showErrors: function(errorMap, errorList) {
$.each( this.successList , function(index, value) {
$(value).popover('hide');
});
$.each( errorList , function(index, value) {
console.log(value.message);
var _popover = $(value.element).popover({
trigger: 'manual',
placement: 'top',
content: value.message,
template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><div class="popover-content"><p></p></div></div></div>'
});
_popover.data('popover').options.content = value.message;
$(value.element).popover('show');
});
}
});
@mcsheffrey
Copy link

In case anyone's wondering it would be _popover.data('bs.popover').options.content = value.message; with Bootstrap 3

@Valherak
Copy link

Pfffew, i was looking for a solution like this for 20 minutes... Thank you Dennys !
And yep, "i was wondering", thank you mcsheffrey ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment