From 7c7e4edb0425b3dc67516995c5856888a0c8a0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= <mail@markus-guenther.de> Date: Mon, 20 Nov 2017 09:18:27 +0100 Subject: [PATCH] [BUGFIX] Prevent javascript error in backend 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/54694 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Andreas Fernandez <typo3@scripting-base.de> Tested-by: Andreas Fernandez <typo3@scripting-base.de> Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> --- .../Resources/Public/JavaScript/LiveSearch.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js index 1f71e7ba3da7..bb712517a9d1 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js @@ -127,11 +127,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'); -- GitLab