I want to trigger a bootstrap modal on submit and not on click as it is programmed to do by default. This is my form and the button that triggers the modal :
<form name="signup-form" action="http://formspree.io/davidgeismar@wetennis.fr" id="conversion_form" method="POST">
<input id="email-input" class="signup-input" type="email" name="email_address" value="" placeholder="Laisse ton mail et reçois le coupon..." title="Please enter a valid email address." required>
<button type="submit" class="submit-btn"data-toggle="modal" data-target="#myModal">GO</button>
</form>
and this is the modal :
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
I tried this as was suggested in a post :
$("#myModal").on("show.bs.modal", function(e){
e.stopPropagation();
})
but this is not working.
What I should do is only trigger the modal when the form is actually submitted. This is after this bunch of JS code :
$("#conversion_form").on("submit", function(e){
e.preventDefault();
var $this = $(this);
var email = $('#email-input').val();
$.ajax({
url: $this.attr('action'), // Le nom du fichier indiqué dans le formulaire
method:"POST",
dataType: "json", // La méthode indiquée dans le formulaire (get ou post)
data: {message: email}, // Je sérialise les données (j'envoie toutes les valeurs présentes dans le formulaire)
success: function(data, textStatus, xhr) {
if(xhr.status==200)
alert('Nous vous tiendrons au courant de nos dernières actu ! \n Wefoot');
$('#email-input').val('');
// $('#myModal').popover('show');
}
});
})