A nice dialog component.
Installation
npm install compose-dialog
- Profit.
Usage
There are a few ways to instantiate a dialog.
DOM only (almost)
Using the data-dialog-title="Some title"
attribute on anything will trigger showing a Dialog with the provided options (as data-dialog
attributes.)
Open a dialog
Delete User
NOTE: You do have to require('compose-dialog')
at some point though.
Programmatically
var Dialog = Dialog
This will handle all there is to handle for showing a Dialog.
Options
dialog-if
Using data-dialog-if="[selector]"
you can only trigger a dialog if the selector is found. So for example if you
only want to show a dialog if a checkbox is checked.
data-dialog-title="Are you sure?" data-dialog-if="#form_id .dangerous-checkbox:checked"
Now when the element is clicked, the event will be stopped and the dialog will be shown only if the checkbox is checked.