Problem with the notify plugin

1

I have a problem with previewing the plugin notification when the form is executed. The form itself is perfect. What I realize is that when it will appear it does not time and the notification closes before it even opens. Thank you very much for the help. link (Notification Plugin)

FORM

 <form method="post" name="formCadastro" id="formCadastro" action="<?php $PHP_SELF; ?>" onsubmit="return confirmacao();">.....</form>

Javascript

 function confirmacao() {
   $.notify("Hello World");
return true;    
}
    
asked by anonymous 21.06.2018 / 22:58

2 answers

1

The problem is that when you submit the form, the page is immediately redirected to the destination entered in action . does not give time to show any message on the screen (even if you try to show, the user will not be able to see).

What you should do is notify after sending when the page loads (or reloaded if the destination is the page itself).

The structure would be this:

<?php
// recebo o formulário
// abro a validação do formulário (um if)
   // se deu tudo certo, chamo o plugin
?>
<script>
$(document).ready(function(){
    $.notify("Formulário enviado com sucesso!");
});
</script>
<?php
// fecho a validação do formulário (fecha o if)
?>

You can also display an error notification if there was a problem validating the form. Just make a else and call script the same way.

    
22.06.2018 / 02:02
-1

Look, guys, I made some modifications and the notify works on the ionic and it shoots with a certain time.

Step here to share with you.

index.html file

<!DOCTYPE html>
<html ng-app="app">
    <head>
        <title>Angular Notify Demo</title>

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link href="angular-notify.css" rel="stylesheet">
        <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body ng-controller="DemoCtrl">

        <div>

            <div class="container">

                <div class="row">
                    <div class="col-md-12">
                        <h2>angular-notify</h2>
                        <p class="lead">Notify - angular - ionic.</p>
                    </div>
                </div>

            <ion-content>
                <br>
                Hora: {{currentTime}}
                <br>
            </ion-content>


        </div>

       <script src="angular.js"></script>
       <script src="angular-notify.js"></script>
       <script src="demo.js"></script>
    </body>
</html>

demo.js

angular.module('app', ['cgNotify']);

    angular.module('app').controller('DemoCtrl',function($interval,$scope,notify,dateFilter) {
        $scope.currentTime = dateFilter(new Date(), 'hh:mm');

        $scope.updateTime = $interval(function() {

            $scope.currentTime = dateFilter(new Date(), 'hh:mm');
            $scope.horaAtual = dateFilter(new Date(), 'hh');
            $scope.minutosAtual = dateFilter(new Date(), 'mm');
            $scope.SegundosAtual = dateFilter(new Date(), 'ss');



            if($scope.minutosAtual == 46 && $scope.SegundosAtual == 0) {

                function demoMessageTemplate() {

                    var messageTemplate = '<span>Agora tudo deu certo!</span> ';

                    notify({
                        messageTemplate: messageTemplate,
                        classes: $scope.classes,
                        scope:$scope,
                        templateUrl: $scope.template,
                        position: $scope.position,
                    });       

                };  // fim demoMessageTemplate

                window.load = demoMessageTemplate();

            } // fim if

        }, 1000); // fim do relogio

    });

Here is every project

link

    
16.10.2018 / 03:53