Skip to content

Instantly share code, notes, and snippets.

@dennysfredericci
Created July 2, 2012 03:56
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • 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');
});
}
});
@kim3er
Copy link

kim3er commented Feb 22, 2013

Very useful, thank you. Rich

@DPSever
Copy link

DPSever commented Oct 22, 2013

Could you provide some insight on implementing this with the bootstrap-wysihtml5 textarea editor (http://jhollingworth.github.io/bootstrap-wysihtml5/)?

@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