Modals

Scripting Custom Scripts

The Modal object is used for all modals, to provide a standard syntax. Scripts can also create custom modals.

actions(options)

Updates the contents of the modal's actions element, or the options at the bottom. A more detailed explanation of the options parameter is available on the Custom Modals page.

submission.modal.actions([
  {
    text: "Destroy",
    type: "primary",
    callback: function(event, modal) {
      modal.hide();
      submission.destroy();
    }
  }
])

body(html)

Updates the contents of the modal's body text.

submission.modal.body("This is a modal's body text.")

destroy()

Removes the modal's element from the page permenantly.

submission.modal.destroy()

element()

Returns the DOM element containing the modal.

submission.modal.element()

force()

Removes transparency from the modal's background, and makes it impossible to exit without DOM manipulation or custom scripting. This method is the reverse of optional

submission.modal.force()

forced()

Returns a boolean value indicating whether the modal is forced to stay open.

if (submission.modal.forced()) {
  submission.modal.title("Please accept the license agreement.")
}

hide()

Hides the modal from the user. This method is the reverse of show.

submission.modal.hide()

optional()

Reverses the effects of force, allowing the user to exit the modal normally.

submission.modal.optional()

show()

Shows the modal to the user. This method is the reverse of hide

submission.modal.show()

title(html)

Updates the contents of the modal's title.

submission.modal.title("My Modal Title")

toggle(visible = this.visible())

Toggles the modal's visibility. This method is a wrapper for show and hide. By default, this method sets the modal's visibility to the opposite of its current value. It can also take an optional attribute to force the visibility status.

submission.modal.toggle()

visible()

Returns a boolean indicating whether the modal is currently visible to the user.

submission.modal.visible()