Dialog
Code
API: unstable
There are two parts to each Dialog:
- A trigger element (like a button) used to open the Dialog
- The Dialog, with a heading, content and controls
Notes:
- The Dialog content has no spacing applied by default. For standard grid spacing wrap the dialog content in an
.ace-panel
element. - If using the HTML API, note the dialog's
aria-labelledby
attribute must match theid
attribute of theh2
inside the dialog header. - If you are managing state directly, note the
aria-hidden
attribute must be updated appropriately when showing and hiding.
Example | Element | Code |
---|---|---|
Dialog trigger | Any button or link can be used as a Dialog trigger. |
Attach an event to your trigger element, then use the Dialog's ID with the
|
Small dialogs are suitable for short messages. |
|
|
Medium dialogs are good for forms. |
Note that the dialog's
|
|
Dialog with footer submit buttons | In some cases the dialog will contain form elements and you need to use the buttons in the dialog footer to submit the form. To do this, the ACE form classes are applied using a DIV (essentially a shim to enable styles) and an unclassed FORM element is placed as the first child of DIALOG. |
|
JavaScript
Methods
Function | Arguments | Description | Example |
---|---|---|---|
init | elementSelector |
Binds all the events and polyfills to dialog element. Init is called by default after the initial page load, so this is only required if you generate a new Dialog that has not been initialised. |
ACE.Dialog.init('.ace-dialog'); |
open | elementSelector | Opens dialog | ACE.Dialog.open('#dialog'); |
close | elementSelector | Closes dialog | ACE.Dialog.close('#dialog'); |
destroy | elementSelector | Removes the event bindings. | ACE.Dialog.destroy('.ace-dialog'); |
Events
Event | Description | Example |
---|---|---|
ace-dialog-displayed | Fires when dialog is displayed |
|
ace-dialog-closed | Fires when dialog is closed |
|
Dependencies
- jQuery 1.10.2 http://jquery.com/
- HTML5 Dialog support: dialog-polyfill https://github.com/GoogleChrome/dialog-polyfill
- HTML5 custom events object: customeventpolyfill.js