Skip to content

Commit 789ab83

Browse files
author
Tom Kaczocha
committed
Passing object instead of name to callback function. Breaking change.
1 parent a9880b8 commit 789ab83

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ $( document ).ready( function( )
6363
heading: 'My Custom Delete Heading',
6464
message: 'Are you sure you want to delete this item?',
6565
data_type: 'post',
66-
callback: function() { console.log( 'deleting item over ajax' ); },
66+
callback: function ( event )
67+
{
68+
// grab original clicked delete button
69+
var button = event.data.originalObject;
70+
// execute delete operation
71+
button.closest( 'tr' ).remove();
72+
},
6773
delete_callback: function() { console.log( 'delete button clicked' ); },
6874
cancel_callback: function() { console.log( 'cancel button clicked' ); }
6975
}

bootstrap-confirm-delete.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
{
5454
var deleteBtn = $( 'a#bootstrap-confirm-dialog-delete-btn' );
5555

56-
deleteBtn.on( 'click', { originalObject: this }, plugin.settings.callback );
56+
deleteBtn.on( 'click', { originalObject: $( this ) }, plugin.settings.callback );
5757

5858
if ( null !== plugin.settings.delete_callback )
5959
{
60-
deleteBtn.on( 'click', { originalObject: this }, plugin.settings.delete_callback );
60+
deleteBtn.on( 'click', { originalObject: $( this ) }, plugin.settings.delete_callback );
6161
}
6262
}
6363
else
@@ -72,7 +72,7 @@
7272

7373
if ( null !== plugin.settings.cancel_callback )
7474
{
75-
$( '#bootstrap-confirm-dialog-cancel-delete-btn' ).on( 'click', { originalObject: this }, plugin.settings.cancel_callback );
75+
$( '#bootstrap-confirm-dialog-cancel-delete-btn' ).on( 'click', { originalObject: $( this ) }, plugin.settings.cancel_callback );
7676
}
7777
};
7878
};

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-confirm-delete",
3-
"version": "1.3.0",
3+
"version": "2.0.0",
44
"homepage": "https://github.com/rawphp/Bootstrap-Confirm-Delete",
55
"authors": [
66
"Tom Kaczocha <tom@rawphp.org>"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bootstrap-confirm-delete",
3-
"version": "1.3.0",
3+
"version": "2.0.0",
44
"description": "Bootstrap confirm delete modal dialog jquery plugin",
55
"main": "bootstrap-confirm-dialog.js",
66
"scripts": {

0 commit comments

Comments
 (0)