Redirect / Close all Dialogs after deleting item

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
ragesoft
Posts: 50
Joined: Fri Feb 23, 2018

02 Sep 2020

Hi,

i have following problem:

i open a normal "SP.UI.ModalDialog.showModalDialog" with de default "Display" form of an item ("Dialog1" for example)
Inside this dialog there is a button to open the Edit-Form in a new dialog ("Dialog2"):

Code: Select all

	SP.UI.ModalDialog.showModalDialog(   
     {  
       url: formUrl,
	   title: "Edit item",
	   dialogReturnValueCallback: closeContactDialog,
	 });
...	 
function closeContactDialog(){
	 SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel,"Close dialog");
}
This "formUrl" is pointing to the SPForm "Edit" and user can edit the item.
The "formUrl" contains the "Source" parameter to redirect user to current page (top-window) (if i dont provide this, user is redirected to the items list if deleting an item).

All fine.
"Close", "Cancel", "Save" => all working correct and closing all modal dialogs ("Dialog1" and "Dialog2").

If the user hit the "Delete Item" button in Ribbon, the spform is closing, but "Dialog2" and "Dialog1" are still open, but "Dialog2" is now empty.
How can i catch the delete event and close all dialogs after successfull deleted item...

Thx a lot!

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

03 Sep 2020

Hello ragesoft,

You can use this code to detect when the Delete button in the ribbon is clicked:

Code: Select all

var button = $( "a[aria-describedby='Ribbon.ListForm.Edit.Actions.DeleteItem_ToolTip']" );
$(button[0]).on('click', function() {
    console.log(true)
})

ragesoft
Posts: 50
Joined: Fri Feb 23, 2018

04 Sep 2020

Sounds good, but if the user clicks "cancel" in the dialgo "Would you like to delete the item" from sharepoint, it also fires.
How can i get the result of this action?

Thx :)

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

08 Sep 2020

Hello ragesoft,

I apologize for my late reply.

Looks like it is not possible to get the output of the confirmation box.

You can create a custom delete button using the code from this post and run your code when the item is deleted.

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests