Last active
December 15, 2015 02:29
-
-
Save phenix-factory/5187519 to your computer and use it in GitHub Desktop.
jQuery: soumettre automatiquement un formulaire.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Il faut simplement placer la classe autosubmit sur la balise form | |
* pour déclencher l'autosoumision du formulaire. | |
*/ | |
$(function () { | |
// Dès qu'il y a un changement dans la formulaire. | |
$(".autosubmit select").on("change", function () { | |
// On demande confirmation du changement de statut. | |
if (confirm("Etes-vous sur ?")) { | |
// L'utilisateur confirme le changement, on change le statut en soumettant le formulaire. | |
$(this).parents(".autosubmit").submit(); | |
} | |
else { | |
// Si l'utilisateur annule le changement, on reset le formulaire pour que le statut ne change pas. | |
$(this).parents(".autosubmit")[0].reset(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment