Tiny Confirmation Modal In Vanilla JavaScript

Category: Javascript , Modal & Popup | September 10, 2020
Author:anderpos
Views Total:919 views
Official Page:Go to website
Last Update:September 10, 2020
License:MIT

Preview:

Tiny Confirmation Modal In Vanilla JavaScript

Description:

A tiny Vanilla JavaScript modal library that adds a custom, animated, beautiful confirm dialog with Promise support to your website/web app.

How to use it:

1. Insert the required JavaScript and CSS files into the document.

<link rel="stylesheet" href="simple-modal.css" />
<script src="simple-modal.js"></script>

2. Create a new confirm dialog and attach a callback to the Promise object.

async function openModal() {
      this.myModal = new SimpleModal("Confirm Dialog!", "Are You Sure", "Sure!", "No");
      try {
        const modalResponse = await myModal.question();
        alert(`The response is ${modalResponse}`);
      } catch(err) {
        console.log(err);
      }
}

3. Launch the confirm dialog.

openModal()

You Might Be Interested In:


Leave a Reply