.. include:: /Includes.rst.txt .. _important-91117: ==================================================================================== Important: #91117 - Use GlobalEventHandler and ActionDispatcher instead of inline JS ==================================================================================== See :issue:`91117` Description =========== In order to reduce the amount of inline JavaScript (with the goal to pave the way towards stronger Content-Security-Policy assignments) lots of inline JavaScript code parts have been substituted by a declarative syntax - basically using HTML :html:`data-*` attributes. The following list collects an overview of common JavaScript snippets and their corresponding substitute using modules :js:`TYPO3/CMS/Backend/GlobalEventHandler` and :js:`TYPO3/CMS/Backend/ActionDispatcher`. `TYPO3/CMS/Backend/GlobalEventHandler` -------------------------------------- .. code-block:: html ' Navigates to URL once selected drop-down was changed (`$value` refers to selected value) .. code-block:: html Navigates to URL once selected drop-down was changed, including selected value (`$data` refers to value of :html:`data-navigate-value`, `$value` to selected value, `$data=~s/$value/` replaces literal `${value}` with selected value in `:html:`data-navigate-value`) .. code-block:: html Checkboxes used to send a particular value when being unchecked can be achieved by using :html:`data-empty-value="0"` - in case this attribute is omitted, an empty string `''` is sent. .. code-block:: html Submits a form once a value has been changed (`$form` refers to paren form element, using CSS selectors like `#formIdentifier` is possible as well) `TYPO3/CMS/Backend/ActionDispatcher` ------------------------------------ .. code-block:: html data-dispatch-action="TYPO3.InfoWindow.showItem" data-dispatch-args-list="be_users,123"> data-dispatch-action="TYPO3.InfoWindow.showItem" data-dispatch-args="["tt_content",123]"> Invokes :js:`TYPO3.InfoWindow.showItem` module function to display details for a given record (of database table `tt_content`, having `uid=123` in the example above) .. index:: Backend, JavaScript, ext:backend