{"id":1768,"date":"2017-02-15T16:42:15","date_gmt":"2017-02-15T15:42:15","guid":{"rendered":"https:\/\/blog.kodono.info\/wordpress\/?p=1768"},"modified":"2017-02-17T11:33:26","modified_gmt":"2017-02-17T10:33:26","slug":"redirect-after-deleting-sharepoint","status":"publish","type":"post","link":"https:\/\/blog.kodono.info\/wordpress\/2017\/02\/15\/redirect-after-deleting-sharepoint\/","title":{"rendered":"Redirect after Deleting [Sharepoint]"},"content":{"rendered":"<p>When I open a dialog for an EditFrom and use the &#8220;Delete Item&#8221; button from the ribbon, then the main page is redirected to the related Sharepoint list. This behavior is very bad for the user experience.<\/p>\n<p>To change it I used the below Javascript code:<\/p>\n<pre class=\"brush:javascript\">\r\n\/\/ replace the Delete Item default action when into a popup\r\n$(document).ready(function() {\r\n  \/\/ if it's in a popup\r\n  if (window !== window.top) {\r\n    $('a[id$=\"_toolBarTbl_RptControls_diidIODeleteItem\"]').attr(\"href\",\"javascript:commonDeleteItem(); return false\")\r\n  }\r\n})\r\n\/\/ now when clicking on the Delete item it will call my own function\r\n\/\/ here I use http:\/\/aymkdn.github.io\/SharepointPlus\/ to show a waiting message and to delete the current item, and then close the modal\r\nfunction commonDeleteItem() {\r\n  $SP().waitModalDialog(\"Deleting...\");\r\n  $SP().list(\"{\"+WPQ2FormCtx.ListAttributes.Id+\"}\").remove({ID:GetUrlKeyValue(\"ID\")}, {\r\n    after:function() {\r\n      $SP().closeModalDialog();\r\n      $SP().closeModalDialog(2);\r\n    }\r\n  })\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When I open a dialog for an EditFrom and use the &#8220;Delete Item&#8221; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","hide_page_title":"","footnotes":""},"categories":[170,13,33],"tags":[123,24,152,158,117],"class_list":["post-1768","post","type-post","status-publish","format-standard","hentry","category-english","category-niveau-intermediaire","category-programmation","tag-english","tag-javascript","tag-niveau-intermediaire","tag-programmation","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1768"}],"version-history":[{"count":1,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1768\/revisions"}],"predecessor-version":[{"id":1769,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/posts\/1768\/revisions\/1769"}],"wp:attachment":[{"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kodono.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}