Open page by clicking Ok - SweetAlert

3

I am testing with the SweetAlert plugin, and would like to open a page by clicking ok , but I could not do it.

I did a test using setTimeout , but there was a lot of gambiarra ...

<html>
    <head>
        <script src="sweet/dist/sweetalert.min.js"></script>
        <link rel="stylesheet" type="text/css" href="sweet/dist/sweetalert.css">
    </head>
    <body>
        <script>
            swal("Sucesso!", "TAG nº<? print($ordem); ?> editada.", "success");
            setTimeout(function() {
                window.location = '/manutencao/EditarTag.php';
            }, 2000);
        </script>
    </body>
</html>
    
asked by anonymous 20.04.2016 / 22:14

1 answer

4

According to documentation you can use an object followed by the function to perform when the button is pressed. It could be something like this:

swal({
    title: "Sucesso!",
    text: "TAG nº<? print($ordem); ?> editada.",
    type: "success",
    closeOnConfirm: false // ou mesmo sem isto
}, function() {
    window.location = 'http://wikipedia.com';
});

jsFiddle: link

    
20.04.2016 / 22:24