Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Example: Show an Alert message

PlugLynn edited this page Apr 24, 2015 · 1 revision

An alert dialog is a simple dialog popup, similar to the native alert(), but with a plug.dj-ised look and feel, and some more capabilities.

Code

var Events = plugModules.require('plug/core/Events')
var ShowDialogEvent = plugModules.require('plug/events/ShowDialogEvent')
var AlertDialog = plugModules.require('plug/views/dialogs/AlertDialog')
function showAlert(options) {
  Events.dispatch(new ShowDialogEvent(ShowDialogEvent.SHOW, new AlertDialog(options)))
}

Usage

showAlert({
  title: 'Alert Message Title',
  message: 'Alert Message Contents. <strong>Can contain HTML!</strong>',
  action: function () {
    // Called when user presses "OK".
  },
  // `action` can also be an Event instance, which will be dispatched
  // when the user presses OK. In this case, the user will join the wait
  // list after pressing OK.
  action: new DJEvent(DJEvent.JOIN),
  // When `forceAction` is true, the action handler will be executed even
  // if the user closes the alert without pressing OK.
  forceAction: false
})
Clone this wiki locally