With rails I can do this:
<%= link_to("Delete", product,
:method => :delete,
data: {confirm: 'Are you sure?.'}
id: 'discard_btn') %>
and I know that when the click is received, a standard javascript confirm dialog will ask the 'Are you sure?' question sending the request if an OK is clicked.
I want to change this plain dialog with a beautiful Bootbox confirm dialog with the same behavior. I tried to do this:
$('#employee_discard').click(function(e){
bootbox.confirm("Are you sure?", function(result) {
// How to send the delete request from this callback?
});
// Prevent the request to be sent. This works/
return false;
});
But my problem is that Bootbox uses callbacks to handle its events and just writing a return true inside the callback will not work.
How can I send a delete request from javascript?
resultvalue then either$.post(delete_url, data, callback_func)or submit a form$(form).submit(). This answer explains the same problem.