If you open a child item from a parent form in EditForm-mode, deleting the child item will cause the parent (top) frame to reload, and you will loose any unsaved data. To work around this problem we need to override the default delete function with some Custom JS. Add this to the DispForm / EditForm of your child item:
if(GetUrlKeyValue("IsDlg") === "1"){
DeleteItemConfirmation = function(){
jQuery("#part1").css("visibility", "hidden");
spjs.dffs.alert({
"title": "Delete item",
"msg": "Please confirm that you want to delete this item.",
"ok": function () {
var dRes = spjs.utility.deleteItem({ "listName": _spPageContextInfo.pageListId, "id": spjs.dffs.data.thisItemID });
if (dRes.success) {
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
} else {
spjs.dffs.alert({
"title": "Error",
"msg": "<span style='color:red;'>" + dRes.errorText + "</span>",
"ok": function () {
spjs.dffs.closeDlg();
}
});
}
},
"cancel": function () {
jQuery("#part1").css("visibility", "visible");
spjs.dffs.closeDlg();
}
});
};
}
Alexander
-
This topic was modified 5 years, 8 months ago by Alexander Bautz. Reason: Moved to correct forum