[BUGFIX] Unbind load event after page tree refresh 70/56170/3
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 15 Mar 2018 14:34:22 +0000 (15:34 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 15 Mar 2018 15:02:11 +0000 (16:02 +0100)
When an action in the page tree is called via the context menu that
enforces a reload of the page tree, the tree is reloaded every time once
the content container is refreshed.

Change the event binding to use `one` to unbind automatically once the
tree was reloaded.

Resolves: #84294
Related: #82970
Releases: 8.7
Change-Id: Ife69dfbceb602a0d610397f313ea539fd9b93711
Reviewed-on: https://review.typo3.org/56170
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benjamin Kluge <b.kluge@neusta.de>
Tested-by: Benjamin Kluge <b.kluge@neusta.de>
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenuActions.js

index ecd250a..2b0a870 100644 (file)
@@ -98,7 +98,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func
   ContextMenuActions.disableRecord = function(table, uid) {
     top.TYPO3.Backend.ContentContainer.setUrl(
       top.TYPO3.settings.RecordCommit.moduleUrl + '&data[' + table + '][' + uid + '][hidden]=1&prErr=1&redirect=' + ContextMenuActions.getReturnUrl()
-    ).on('load', function() {
+    ).one('load', function() {
       top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
     });
   };
@@ -106,7 +106,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func
   ContextMenuActions.enableRecord = function(table, uid) {
     top.TYPO3.Backend.ContentContainer.setUrl(
       top.TYPO3.settings.RecordCommit.moduleUrl + '&data[' + table + '][' + uid + '][hidden]=0&prErr=1&redirect=' + ContextMenuActions.getReturnUrl()
-    ).on('load', function() {
+    ).one('load', function() {
       top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
     });
   };
@@ -134,7 +134,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func
       if (e.target.name === 'delete') {
         top.TYPO3.Backend.ContentContainer.setUrl(
           top.TYPO3.settings.RecordCommit.moduleUrl + '&redirect=' + ContextMenuActions.getReturnUrl() + '&cmd[' + table + '][' + uid + '][delete]=1&prErr=1'
-        ).on('load', function() {
+        ).one('load', function() {
           if (table === 'pages' && top.TYPO3.Backend.NavigationContainer.PageTree) {
             top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
           }
@@ -206,7 +206,7 @@ define(['jquery', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/Backend/Severity'], func
 
       top.TYPO3.Backend.ContentContainer.setUrl(
         top.TYPO3.settings.RecordCommit.moduleUrl + url
-      ).on('load', function() {
+      ).one('load', function() {
         if (table === 'pages' && top.TYPO3.Backend.NavigationContainer.PageTree) {
           top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
         }