jquery.confirm
Confirm dialogs for buttons and links.
Requirements
- jQuery > 1.8
- Bootstrap 3 for the modals
If you use Bootstrap 2, you can use any 1.x version. From 2.0 and onwards, Bootstrap 3 is required.
Installation
The library can be downloaded manually or installed with npm:
$ npm install way2web.jquery.confirm
Usage
Go to home
;
Any click on the link will pop up a dialog asking the user to confirm the action.
Options
List of the options:
text
: Text to display in the dialogtitle
: Title of the dialog (can be empty, the dialog will not have a header then)confirm
: Handler executed when the user confirmscancel
: Handler executed when the user cancelsconfirmButton
: Label of the confirm buttoncancelButton
: Label of the cancel button, if set to false no button at all.post
: If false (default) and no confirm handler is set, redirects the user to the URL of the button/link with a GET request. If true, redirects with a POST request (like a form submission).submitForm
: If false (default) it has no effect. If true, it submit the form target element.confirmButtonClass
: HTML class for the confirmation button, defaults tobtn-primary
.cancelButtonClass
: HTML class for the cancel button, defaults tobtn-default
.dialogClass
: HTML class for the dialog, defaults tomodal-dialog
.modalOptionsBackdrop
: Backdrop option for modal.modalOptionsKeyboard
: Keyboard option for bootsrap modal.
Example:
Delete the comment
;
You can also use data-
attributes to customize the confirmation dialog:
Delete the user
;
Manual triggering
You can manually trigger the confirmation dialog:
// Will immediately show the confirmation popup$;
Remember that if you trigger the confirmation dialog manually, you must provide a confirm
callback (as shown above).
Global configuration
You can configure some options globally, for example if you translate the messages:
$confirmoptions = text: "Are you sure?" title: "" confirmButton: "Yes" cancelButton: "Cancel" post: false submitForm: false confirmButtonClass: "btn-warning" cancelButtonClass: "btn-default" dialogClass: "modal-dialog"
Contributing
Pull requests and bug reports are welcome! Be aware that you do not need to generate the minified version yourself, it will be generated by a release manager (for security reasons).
Change log
License
This software is released under the MIT license.