22
33Bootstrap confirm delete modal dialog jquery plugin
44
5-
65## Installation
7- You can install with [ bower] ( http://bower.io/ ) or [ npm] ( https://www.npmjs.com/ ) .
6+
7+ You can install from [ npm] ( https://www.npmjs.com/package/bootstrap-confirm-delete ) .
88
99``` sh
10- $ bower install bootstrap-confirm-delete
10+ $ yarn add bootstrap-confirm-delete
1111$ npm install --save bootstrap-confirm-delete
1212```
1313
1414## Dependencies
15+
1516This plugin depends on the following:
17+
1618- jquery >= 1.9.1
1719- bootstrap >= 3.3.5
1820
1921NOTE: This plugin has not been tested with versions prior to these.
2022
21-
2223## Basic Usage
24+
2325This plugin will intercept the delete event on configured page elements. In this example it will block the deletion click
2426on any links or buttons that have the 'delete' class on them.
2527
@@ -32,94 +34,111 @@ on any links or buttons that have the 'delete' class on them.
3234<a href =" server.php" class =" delete" data-type =" post" >Delete</a >
3335```
3436
35- Initialise the plugin either in <script ></script > tags on the html page or in an external .js script.
37+ Initialise the plugin either in <script ></script > tags on the html page or in an external .js script.
3638
3739``` js
38- $ ( document ).ready ( function ( )
39- {
40- $ ( ' .delete' ).bootstrap_confirm_delete ( );
41- } );
40+ $ (document ).ready (() => {
41+ $ (' .delete' ).bootstrap_confirm_delete ();
42+ });
4243```
4344
4445Notice the 'data-type' attribute on the link. The plugin will use this attribute if set to show a custom delete message. For example,
4546
46- Heading: 'Delete Post'
47+ Heading: 'Delete Post'
4748
48- Message: 'Are you sure you want to delete this post?'
49+ Message: 'Are you sure you want to delete this post?'
4950
5051### Example
52+
5153This example shows all the available options:
5254
5355``` js
54- $ ( document ).ready ( function ( )
55- {
56- $ ( ' .delete ' ). bootstrap_confirm_delete (
57- {
58- debug : false ,
59- heading : ' My Custom Delete Heading ' ,
60- message : ' Are you sure you want to delete this item? ' ,
61- btn_ok_label : ' Yes ' ,
62- btn_cancel_label : ' Cancel ' ,
63- data_type : ' post ' ,
64- callback : function ( event )
65- {
66- // grab original clicked delete button
67- var button = event . data . originalObject ;
68- // execute delete operation
69- button . closest ( ' tr ' ). remove ( );
70- },
71- delete_callback : function () { console . log ( ' delete button clicked ' ); },
72- cancel_callback : function () { console .log ( ' cancel button clicked' ); }
73- }
74- );
75- } );
56+ $ (document ).ready (() => {
57+ $ ( ' .delete ' ). bootstrap_confirm_delete ( {
58+ debug : false ,
59+ heading : ' My Custom Delete Heading ' ,
60+ message : ' Are you sure you want to delete this item? ' ,
61+ btn_ok_label : ' Yes ' ,
62+ btn_cancel_label : ' Cancel ' ,
63+ data_type : ' post ' ,
64+ callback : ( event ) => {
65+ // grab original clicked delete button
66+ var button = event . data . originalObject ;
67+ // execute delete operation
68+ button . closest ( ' tr ' ). remove ();
69+ },
70+ delete_callback : () => {
71+ console . log ( ' delete button clicked ' );
72+ },
73+ cancel_callback : () => {
74+ console .log (' cancel button clicked' );
75+ },
76+ } );
77+ });
7678```
7779
7880### See test directory for a more complete example
7981
8082## Options
83+
8184Bootstrap Confirm Delete plugin comes with several optional settings.
8285
8386### debug
87+
8488Debug mode will output events and information to the console.
8589
8690### heading
91+
8792This is for setting a custom modal heading.
8893
8994### message
95+
9096Setting a custom delete message/question.
9197
9298### btn_ok_label
99+
93100Set the confirm label text
94101
95102### btn_cancel_label:
103+
96104Set the cancel label text
97105
98106### data_type
107+
99108Used if heading & message are not provided
100109
101110### callback
111+
102112Will fire if responding to a button click that has no href attribute.
103113
104114Use this callback to do any deletions from a button click.
105115Parameters:
106- * data (data.originalObject contains the originally clicked object)
116+
117+ - data (data.originalObject contains the originally clicked object)
107118
108119### delete_callback
120+
109121Will fire when the delete button is clicked and a handler is provided.
110122Parameters:
111- * data (data.originalObject contains the originally clicked object)
123+
124+ - data (data.originalObject contains the originally clicked object)
112125
113126### cancel_callback
127+
114128Will fire when the cancel button is clicked and a handler is provided.
115129Parameters:
116- * data (data.originalObject contains the originally clicked object)
117130
131+ - data (data.originalObject contains the originally clicked object)
118132
119133## License
120- Copyright © ; 2015 Tom Kaczocha < tom@rawphp.org >
134+
135+ Copyright © ; 2015-2019 Tom Kaczocha < tom@rawphp.org >
136+
121137Licensed under the MIT license.
122138
123139## Contributors
140+
124141Special thanks to:
125- * [ mpecan] ( https://github.com/mpecan )
142+
143+ - [ mpecan] ( https://github.com/mpecan )
144+ - [ iwansusanto] ( https://github.com/iwansusanto )
0 commit comments