[BUGFIX] Prevent javascript error in backend 10/54710/2
authorMarkus Günther <mail@markus-guenther.de>
Mon, 20 Nov 2017 08:18:27 +0000 (09:18 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 20 Nov 2017 19:51:38 +0000 (20:51 +0100)
Adding a condition to check if a backend user has permissions on the
search to prevent a JS error while initializing the autocomplete module.

Fixes: #82969
Releases: master, 8.7, 7.6
Change-Id: If2827902443ff7411d9b2c1050213be3e0d78fb6
Reviewed-on: https://review.typo3.org/54710
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js

index 330f624..fb69d96 100644 (file)
@@ -112,11 +112,13 @@ define([
                        TYPO3.ModuleMenu.App.showModule('web_list', 'id=0&search_levels=-1&search_field=' + encodeURIComponent($(searchFieldSelector).val()));
                        $(searchFieldSelector).val('').trigger('change');
                });
-               $('.' + $(searchFieldSelector).autocomplete().options.containerClass).on('click.autocomplete', '.dropdown-list-link', function(evt) {
-                       evt.preventDefault();
-                       jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid'));
-                       $(searchFieldSelector).val('').trigger('change');
-               });
+               if ($(searchFieldSelector).length) {
+                       $('.' + $(searchFieldSelector).autocomplete().options.containerClass).on('click.autocomplete', '.dropdown-list-link', function (evt) {
+                               evt.preventDefault();
+                               jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid'));
+                               $(searchFieldSelector).val('').trigger('change');
+                       });
+               }
 
                // Unset height, width and z-index
                $(toolbarItem).removeAttr('style');