Another hidden treasure in the PW Backend:
PW 3.0.61 introduced the VEX library for dialogs: https://processwire.com/blog/posts/processwire-3.0.61-master/#admin-and-ui
This is how you can use them in your custom admin pages:
In your module's php load the vex library (eg in the ready() method of your module - init() might not work as it might load too early!)
$this->wire('modules')->get('JqueryUI')->use('vex');
Then in your javascript:
// show confirm dialog
ProcessWire.confirm('Are you sure you want to delete this E-Mail?', function() {
// on confirm
$i.removeClass('fa-trash').addClass('fa-spin fa-spinner');
$.get('./trash/?mailid=' + $a.data('mailid'), function() {
$a.closest('.RockGridWrapper').find('.rockgridbutton.refresh').click();
});
},
function() {
// on abort
grid.api().deselectAll();
});
Result:
I opened a pull request with a little fix for handling clicks on the CANCEL button. If you want to support it, give it a thumb: https://github.com/processwire/processwire/pull/108