[BUGFIX] Start click binding only after DOM is ready 36/52136/3
authorFrank Naegler <frank.naegler@typo3.org>
Thu, 23 Mar 2017 13:46:51 +0000 (14:46 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 24 Mar 2017 14:25:08 +0000 (15:25 +0100)
This patch fixes a loading issue on poor internet connections.
In case of a slow internet connection the icons are not loaded and the
click binding does not work. A DOM ready check should solve the issue.

Resolves: #80416
Releases: master, 7.6
Change-Id: Ia79f14e9dbe0b44a22c5916073b4649211b0bd7b
Reviewed-on: https://review.typo3.org/52136
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Tabea Oertel <tabea.oertel@dkd.de>
Tested-by: Tabea Oertel <tabea.oertel@dkd.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php

index a79501f..e5af068 100644 (file)
@@ -233,14 +233,18 @@ class SelectSingleElement extends AbstractFormElement
 
         $resultArray['requireJsModules'][] = ['TYPO3/CMS/Backend/FormEngine/Element/SelectSingleElement' => implode(LF, [
             'function(SelectSingleElement) {',
-                'SelectSingleElement.initialize(',
-                    GeneralUtility::quoteJSvalue('#' . $selectId) . ',',
-                    '{',
-                        'onChange: function() {',
-                            implode('', $parameterArray['fieldChangeFunc']),
-                        '}',
-                    '}',
-                ');',
+                'require([\'jquery\'], function($) {',
+                    '$(function() {',
+                        'SelectSingleElement.initialize(',
+                            GeneralUtility::quoteJSvalue('#' . $selectId) . ',',
+                            '{',
+                                'onChange: function() {',
+                                    implode('', $parameterArray['fieldChangeFunc']),
+                                '}',
+                            '}',
+                        ');',
+                    '});',
+                '});',
             '}',
         ])];