When I open a dialog for an EditFrom and use the « Delete Item » button from the ribbon, then the main page is redirected to the related Sharepoint list. This behavior is very bad for the user experience.
To change it I used the below Javascript code:
// replace the Delete Item default action when into a popup $(document).ready(function() { // if it's in a popup if (window !== window.top) { $('a[id$="_toolBarTbl_RptControls_diidIODeleteItem"]').attr("href","javascript:commonDeleteItem(); return false") } }) // now when clicking on the Delete item it will call my own function // here I use http://aymkdn.github.io/SharepointPlus/ to show a waiting message and to delete the current item, and then close the modal function commonDeleteItem() { $SP().waitModalDialog("Deleting..."); $SP().list("{"+WPQ2FormCtx.ListAttributes.Id+"}").remove({ID:GetUrlKeyValue("ID")}, { after:function() { $SP().closeModalDialog(); $SP().closeModalDialog(2); } }) }