Jump to main content Jump to doc navigation

MODx.msg

Extends: Ext.Component Key Features: AJAX connector features.

The MODx.msg class provides the functionality of the Ext.MessageBox class, with the added benefit of using an AJAX callback function (for confirmation dialogs). Simply provide a URL and optional parameters and a connector request will be sent after the user confirms the prompt. It defaults to a minimum width of 200px.

Methods

alert

MODx.msg.alert(title,text,fn,scope)

Used to display an alert dialog box on the page. Example:

MODx.msg.alert('Warning!','You are out of space! We should clear the cache.',function() {
  MODx.clearCache();
},MODx);

confirm

MODx.msg.confirm(config)

Loads a confirmation dialog that prompts the user for a Yes/No response. If Yes is selected, fires an AJAX request to a specific connector. The properties for the config parameter are:

Name Description
title The title of the confirmation box.
text The text in the confirmation box.
minWidth The confirmation popup will automatically choose a size, but to make sure it's at least a certain width provide an integer value representing the width. (Added in 3.0.0-rc2)
url The URL to send the AJAX request to.
params The REQUEST params to send with the AJAX request.
listeners Any listeners to look for on the request.

An example:

MODx.msg.confirm({
   title: 'Are you sure?',
   text: 'Do you want to delete the world? This is irreversible.',
   url: 'http://rest.endofdays.com/armageddon/',
   params: {
      deleteWorld: true
   },
   listeners: {
        'success':{fn: function(r) {
             MODx.clearCache(); /* clear cache after world destruction, so we dont have latent data */
        },scope:true}
   }
});

MODx.msg.confirm Custom Events

MODx.msg.confirm adds a few custom events that fire:

Name Description
success Fires on a successful response from the AJAX submission.
failure Fires on a failed response from the AJAX submission.
cancel Fires when the user cancels the confirmation dialog.

status

MODx.msg.status(opt)

Loads a temporary status message in the top-right of the screen, that fades away. The properties for the opt parameter are:

Name Description Default
title Optional. The title of the message.
message The text of the status message.
dontHide If true, will not automatically hide the status message. Will stay until it is clicked. false
delay The number of seconds to show the message. 1.5

You could use this in custom manager pages to provide confirmation your object was saved. You could add something like this to your FormPanel definition:

        listeners: {
            'success': function (res) {
                MODx.msg.status({
                    title: _('save_successful'),
                    message: res.result['message'],
                    delay: 3
                });
            }
        }

The 'success' listener is part of modExt and comes with MODx.FormPanel.

See Also

  1. MODExt MODx Object
  2. MODExt Tutorials
    1. Ext JS Tutorial - Message Boxes
    2. Ext JS Tutorial - Ajax Include
    3. Ext JS Tutorial - Animation
    4. Ext JS Tutorial - Manipulating Nodes
    5. Ext JS Tutorial - Panels
    6. Ext JS Tutoral - Advanced Grid
    7. Ext JS Tutorial - Inside a CMP
  3. MODx.combo.ComboBox
  4. MODx.Console
  5. MODx.FormPanel
  6. MODx.grid.Grid
  7. MODx.grid.LocalGrid
  8. MODx.msg
  9. MODx.tree.Tree
  10. MODx.Window

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • Chris Fickling
  • CrewMark
  • deJaya
  • eydolan
  • Lefthandmedia
  • Murray Wood
  • Following Sea
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$306 per month—let's make that $500!

Learn more