Modal

Forms Developer Guides Scripting Interface Modal

The Modal object includes methods for creating modals and updating existing modals.

  • actions — Change a modal's actions, or return the current actions.
  • body — Change a modal's body, or return the current body.
  • destroy — Destroy a modal, removing it from the page.
  • hide — Hide a modal from the user.
  • load — Built-in modals may be lazily loaded from the server. The show method returns a promise because it may call this.
  • show — Shows a modal to the user.
  • size — Change a modal's size, or return the current size.
  • title — Change a modal's title, or return the current title.
  • toggle — Show or hide a modal, depending on the current state.
  • visible — Returns a boolean indicating whether the modal is visible.

Creating Modals

title = "Title"
body = "Body"

actions = [
  {
    text: "OK",
    callback: function() { console.log("hi") },
    type: "primary"
  },
  {
    text: "Cancel",
    type: "secondary"
  }
]

options = {
  size: "medium"
}

Modal.new(title, body, actions, options)

See the size documentation for a list of modal sizes, and the actions documentation for action syntax.