bs5dialog

Introduction

Loads content or remote page into a Bootstrap 5 modal dialog with customizable options.supports default dragging, zooming, and maximizing of the modal window.

Usage Example

ESM

import { load } from '@ymlluo/bs5dialog';

load('https://example.com', {
  title: 'Example Modal',
  type: 'primary',
  size: 'md',
  id: 'example-modal',
  centered: true,
  scrollable: true,
  maximize: false,
  backdrop: true,
  focus: true,
  keyboard: true,
  draggable: true,
  resizable: true,
  btnOkText: 'OK',
  btnCancelText: 'Cancel',
  onShow: () => console.log('Modal is shown'),
  onShown: () => console.log('Modal is fully shown'),
  onHide: () => console.log('Modal is hiding'),
  onHidden: () => console.log('Modal is fully hidden'),
  isForm: true,
  onSubmit: () => console.log('Modal is submitted'),
  onSubmitSuccess: () => console.log('Modal is successfully submitted'),
  onSubmitError: () => console.log('Modal submission error'),
  onSubmitDone: () => console.log('Modal submission is done')
});

CJS

const { load } = require('@ymlluo/bs5dialog');

load('https://example.com', {
  title: 'Example Modal',
  type: 'primary',
  size: 'md',
  id: 'example-modal',
  centered: true,
  scrollable: true,
  maximize: false,
  backdrop: true,
  focus: true,
  keyboard: true,
  draggable: true,
  resizable: true,
  btnOkText: 'OK',
  btnCancelText: 'Cancel',
  onShow: () => console.log('Modal is shown'),
  onShown: () => console.log('Modal is fully shown'),
  onHide: () => console.log('Modal is hiding'),
  onHidden: () => console.log('Modal is fully hidden'),
  isForm: true,
  onSubmit: () => console.log('Modal is submitted'),
  onSubmitSuccess: () => console.log('Modal is successfully submitted'),
  onSubmitError: () => console.log('Modal submission error'),
  onSubmitDone: () => console.log('Modal submission is done')
});

UMD

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Load Example</title>
    <!-- Include Bootstrap 5 CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../bs5dialog.css">

    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.4/axios.js"></script>
    <script src="../bs5dialog.js"></script>  </head>
  </head>
  <body>
    <button id="example-button">Open Modal</button>
    <script>
      const exampleButton = document.getElementById('example-button');
      exampleButton.addEventListener('click', () => {
        bs5dialog.load('./form.html', {
          title: 'Example Modal',
          type: 'primary',
          size: 'md',
          id: 'example-modal',
          centered: true,
          scrollable: true,
          maximize: false,
          backdrop: true,
          focus: true,
          keyboard: true,
          draggable: true,
          resizable: true,
          btnOkText: 'OK',
          btnCancelText: 'Cancel',
          onShow: () => console.log('Modal is shown'),
          onShown: () => console.log('Modal is fully shown'),
          onHide: () => console.log('Modal is hiding'),
          onHidden: () => console.log('Modal is fully hidden'),
          isForm: true,
          onSubmit: () => console.log('Modal is submitted'),
          onSubmitSuccess: () => console.log('Modal is successfully submitted'),
          onSubmitError: () => console.log('Modal submission error'),
          onSubmitDone: () => console.log('Modal submission is done')
        });
      });
    </script>
  </body>
</html>

Parameters

List of Event Listeners

If options.isForm is true, when the form is submitted