Options
All
  • Public
  • Public/Protected
  • All
Menu

Example

const modal = new Modal({
  host: document.body, // by default
  title: 'title',
  content:
    `<p>click <a data-type="close">here</a> to close.</p>
     <p>click <a data-type="cancel">here</a> to cancel.</p>
     <p>click <a data-type="confirm">here</a> to confirm.</p>`,
  animation: true, // by default
  event: 'click', // by default
  autoclose: true. // by default
  actions: [
    { type: 'close', label: 'close' },
    { type: 'cancel', label: 'cancel' },
    { type: 'confirm', label: 'ok' },
    {
      label: 'search',
      redirect: 'https://www.google.com/search?q=',
      target: '_blank',
    },
    {
      label: 'noop', callback: function () {
        this.close()
      }
    },
  ],
});

modal.open().then(() => {});
modal.close().then(() => {});

modal.on('open', () => {});
modal.on('close', () => {});
modal.on('cancel', () => {});
modal.on('confirm', () => {});

Hierarchy

  • EventEmitter
    • Modal

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

el

Methods

close

  • close(): Promise<void>
  • Close modal

    Returns Promise<void>

    promise

destroy

  • destroy(): void
  • Destroy instance, remove all listeners

    Returns void

off

  • off(type: string, handler: function): void
  • Remove an event handler for the given type.

    Parameters

    • type: string

      Type of event to unregister handler from, or "*"

    • handler: function

      Handler function to remove

        • (event?: any): void
        • Parameters

          • Optional event: any

          Returns void

    Returns void

on

  • on(type: string, handler: function): void
  • Register an event handler for the given type.

    Parameters

    • type: string

      Type of event to listen for, or "*" for all events

    • handler: function

      Function to call in response to given event

        • (event?: any): void
        • Parameters

          • Optional event: any

          Returns void

    Returns void

open

  • open(): Promise<void>
  • Open modal

    Returns Promise<void>

    promise

Static config

Generated using TypeDoc