Custom Modal Version 2.0

Originally created as a side project for BIT Final Project. The Custom Modal Now Support Custom Alerts.
Instead of using native confirm alerts from JS now you can use beautifully animated custom confirm alerts

success
Confirm Modal Alert
Dependencies
bootstrap logo Bootstrap 5.0+
Usage
showCustomConfirm(msg,result);
Getting Started

To get started, include bootstrap css, bootstrap js and custom Modal files in your webpage

<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" type="text/javascript"></script>
<script src="customModal_V2/resources/js/customModal@2.0.min.js" type="text/javascript"></script>

Then call showCustomConfirm() to whatever you want to trigger it

<script> showCustomConfirm("Hello",function (result){}); </script>
Documentation
Example Explanation
msg Insert your message here
result catch the result of the user confirmation (callback function)
  1. showCustomConfirm("Are You sure?", function (result){});

    • This line calls the showCustomConfirm function, passing two arguments:
      • The first argument is the message to be displayed in the confirmation modal. In this case, it's the string "Are you sure?".
      • The second argument is a callback function. This function will be executed once the user interacts with the modal, and it takes a single parameter (result).

  2. Callback Function:

    • The callback function checks the value of result, which is the user's choice in the confirmation modal.
    • If result is true, it means the user clicked "Yes" in the modal, and an alert is shown with the message "User clicked Yes".
    • If result is false, it means the user clicked "No" or closed the modal without clicking "Yes", and an alert is shown with the message "User clicked No or closed the modal".
    • In this example, it displays an alert message, but you can replace it with your desired logic.

Download v2.0

Made with ❤️ - Malindu Prabodhitha