bsky
bsky

Reputation: 20222

Datatables show warning when deleting rows

In order to delete selected rows from an instance of Datatables, I can use:

var rows = table
    .rows( '.selected' )
    .remove()
    .draw();

However, I would also like to display a warning message to the user, like this:

var rows = table
    .rows( '.selected' )
    .showWarning('Are you sure you want to delete the selected rows?')
    .remove()
    .draw();

How can I display a warning to the user before deleting rows?

Upvotes: 2

Views: 116

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58880

You can use confirm() as shown below:

if(confirm('Are you sure you want to delete the selected rows?')){
   var rows = table
      .rows( '.selected' )
      .remove()
      .draw();
}

Upvotes: 2

Related Questions