jqBootstrapValidation
jqBootstrapValidation copied to clipboard
Destroy doesn't unbind submit event
When you make a destroy call like
$modalBody.find("input,select,textarea").jqBootstrapValidation("destroy");
it doesn't unbind the form submit event. So when you call a second time the same jqBootstrapValidation method because you have rebuilted another form in the same div ($modalBody for my part) submitSuccess is called twice. When you call again it has been called third ...
To correct this I have made this little modification in destroy function :
destroy : function( ) {
return this.each(
function() {
var
$this = $(this),
$controlGroup = $this.parents(".control-group").first(),
$helpBlock = $controlGroup.find(".help-block").first();
//lgm42 modification
$(this.form).unbind("submit");
//End of modification
// remove our events
$this.unbind('.validation'); // events are namespaced.
It is not very lovely because we unbind in the each loop. I think there is a beautiest method...