A jQuery plugin for adding an easy 'are you sure' confirmation pop-up before the handler in .on() is called.
##Changelog
- v0.1.2 - ClassPrepend option is now also used for the inner elements of the pop-up
- v0.1.1 - Added a handler for answer 'no'
- v0.1.0 - Initial release
##What does this plugin?
The confirmOn plugin shows a confirmation box when the provided events are triggered. It works exactly like jQuery's .on() but with a confirmation step between the event and the handler. When the user answers the confirmation dialog, the handler is called with the answer as a parameter, so you can decide what to do next.
##Installing
Grab jquery.confirmon.js from the repository and insert the following line after the jQuery script in your code:
<script src="jquery.confirmon.js"></script>That's all.
Maybe you want to use the stylesheet that creates a screenwide overlay and a centered box. No problem, just add jquery.confirmon.css to your html.
<link rel="stylesheet" type="text/css" href="jquery.confirmon.css"/>Since there are only a few classes involved you can insert the classes into your existing stylesheet for performance sake.
##Usage
Use .confirmOn() the same way as you use jQuery's .on(). Check http://api.jquery.com/on/ for the documentation.
There are some options that can be set to customize the plugin. Add them as the first argument of .confirmOn().
{
questionText: 'Are you sure?', // The confirmation question
classPrepend: 'confirmon', // Use another prefix for the classes used by the plugin
textYes: 'Yes', // Text on the button the user clicks when the handler should be called
textNo: 'No' // Text on the button the user clicks when the handler should not be called
}##Example
$('#myButton').confirmOn('click', function(e, confirmed){
if(confirmed) deleteSomethingImportant();
else {
//If we need to, we can do some actions here if the user cancelled the confirmation
}
})When #myButton is clicked, this confirmation box pops up:

Check out this live sample (and its source).
##Maintainers People who've contributed:
- Dag Jomar Mersland | MazeMap
- [Maxime Thirouin | MoOx] (https://github.com/MoOx)
