TrederusMaximus
2 years ago

Sweetalert SWAL is not defined - after NPM install

Posted 2 years ago by TrederusMaximus

Hello all,

I am still relatively new to using NPM so I do not really understand what the porblem is.

I have installed sweetalert by the following command:

npm install sweetalert --save

Now it appears if I do npm list and I can also find it within the node_modules folder.

However: If I try to call it this way:

    <script>
         $('button#orderButtonId').on('click', function(){

          swal({
            title: "Are you sure?",
            text: "Die Bestellung wird aufgegeben und es können keine weiteren Artikel hinzugefügt werden!", type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Ja, Bestellung aufgeben!",
            closeOnConfirm: false
          },
               function(){
            $("#orderFormId").submit();
          });
        })
    </script>

I get the message:

73:127 Uncaught ReferenceError: swal is not defined(…)

Any ideas what I can do?

Thanks in advance! :-)

Please sign in or create an account to participate in this conversation.