Simple Alertify Alert message only flashes on screen

790 views Asked by At

I'm trying to replace the standard system alert with something prettier, and thought I would give Alertify a try. The behavior is not as expected, the alert box appears on screen for only a second before disappearing.

I'm not sure what I'm doing wrong?

Function:

        function confirmation() {
            alertify.alert("here is a message")
        }

HTML:

<asp:Button ID="SubmitButton" runat="server" CausesValidation="True" CommandName="Insert" CssClass="formButton" Text="Submit" OnClientClick ="confirmation();"/>

Any assistance would be greatly appreciated.

1

There are 1 answers

0
Angus McRitchie On

Make sure you're loading all the required files as shown on AlertifyJS Getting Started section and further instructions on the alert() docs.
Here's a working example:

// on page load
alertify.alert('On page load');

// inside function
function showPrettyAlert() {
  alertify.alert('From function');
}
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!-- alertify -->
<script src="//cdn.jsdelivr.net/npm/[email protected]/build/alertify.min.js"></script>

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/build/css/alertify.min.css"/>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/build/css/themes/default.min.css"/>

<button onclick="showPrettyAlert();">Show pretty alert</button>

AlertifyJS is awesome, I've used it in many projects. Make sure you check out the confirm(), prompt() and notify() methods too.