1
I find the following mistake:
<form action="" method="post" onsubmit="sweetalert(1)">
Dados aqui !!!
<input type="button" id="selectall-game-button" label="check all" value="Selecionar tudo">
<input type="submit" id="delete-game-button" value="Eliminar" style="display:none;"/>
JS
function sweetalert(x) {
switch (x) {
case 1:
swal({
title: "Aviso!",
text: "Tens a certeza que queres apagar este/s ficheiro/s?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Sim, eliminar!",
cancelButtonText: "Não, cancelar!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm) {
if (isConfirm) {
swal("Eliminado!", "O/s ficheiro/s foi/foram eliminado/s!", "success");
} else {
swal("Cancelado", "A operação foi cancelada, os ficheiros foram salvos!", "error");
}
});
break;
}
}
I have tested only with Alert and confirm on onsubmit and everything went well. But when putting this script on onsubmit
it does not "hold" the function, immediately deletes the data before confirming whether or not to delete the file.
It didn’t work. : ss Can you do a Jsfiddle please?
– thecreator
@thecreator http://jsfiddle.net/7whfdcs5/. But there is no time to show the warning that the files have been deleted, the form is submitted first. If you want to prevent the page from reloading, you need to use ajax instead of submitting the form (which would be the subject of a separate question if you have questions about how to do it).
– bfavaretto
Still do not give, in your example everything works as I intend, but here not updated the code
– thecreator
I got it, there was a mistake in my code
onsubmit="sweetalert(1);" return false;"
->onsubmit="sweetalert(1); return false"
– thecreator