[BUGFIX] Start click binding only after DOM is ready 43/52143/3
authorFrank Naegler <frank.naegler@typo3.org>
Thu, 23 Mar 2017 13:46:51 +0000 (14:46 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Fri, 24 Mar 2017 14:41:52 +0000 (15:41 +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/52143
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php

index 0c7605b..808b868 100644 (file)
@@ -249,17 +249,21 @@ class SelectSingleElement extends AbstractFormElement
         $resultArray['html'] = $html;
         $resultArray['requireJsModules'][] = ['TYPO3/CMS/Backend/FormEngine/Element/SelectSingleElement' => implode(LF, [
             'function(SelectSingleElement) {',
-                'SelectSingleElement.initialize(',
-                    GeneralUtility::quoteJSvalue('#' . $selectId) . ',',
-                    '{',
-                        'onChange: function() {',
-                            implode('', $parameterArray['fieldChangeFunc']),
-                        '},',
-                        'onFocus: function() {',
-                            $parameterArray['onFocus'],
-                        '},',
-                    '}',
-                ');',
+                'require([\'jquery\'], function($) {',
+                    '$(function() {',
+                        'SelectSingleElement.initialize(',
+                            GeneralUtility::quoteJSvalue('#' . $selectId) . ',',
+                            '{',
+                                'onChange: function() {',
+                                    implode('', $parameterArray['fieldChangeFunc']),
+                                '},',
+                                'onFocus: function() {',
+                                    $parameterArray['onFocus'],
+                                '}',
+                            '}',
+                        ');',
+                    '});',
+                '});',
             '}',
         ])];