Actions

Forms Developer Guides Scripting Interface Modal

ACTIONS(actions)

var modal = Modal.new();

modal.actions([
  {
    text: "OK",
    callback: function() { console.log("OK!") }
  }
  {
    text: "Cancel"
  }
])

Modal actions are set with an array of objects - one for each action. The action objects can set the following options:

  • text — The action's text.
  • callback — A callback function triggered when the action is clicked.
  • close — A boolean, representing whether the modal should be closed when the action is clicked. By default this is true.
  • align — A string, either "left" or "right", controlling which side the action appears on.
  • type — A string, either "primary" or "secondary". Primary actions are highlighted with a colored background, while secondary actions appear with lighter text. By default this is "secondary".
  • if — A function triggered when the actions are set, with the modal passed as an argument. Use this to build a standard array of actions, with some actions conditionally disabled. For example: function(modal) { return modal.title() == "Example"; } will only show the action if the modal's title is "Example".