n00n
n00n

Reputation: 664

How to add jquery file on top of the backend

Need to start jquery with document.ready to organize some Things in my TYPO3 backend.

I am using for my backend CSS this way:

$GLOBALS['TBE_STYLES']['skins']['myext'] = array();
$GLOBALS['TBE_STYLES']['skins']['myext']['name'] = 'My improved t3skin';
$GLOBALS['TBE_STYLES']['skins']['myext']['stylesheetDirectories'] = array(
    'backend' => 'EXT:'.$_EXTKEY.'/Resources/Public/css/backend/'
);

is there any similar way to load jquery (backend.js) file?

Regards Dirk

Upvotes: 0

Views: 1125

Answers (1)

mtness
mtness

Reputation: 1024

By default, jQuery 2.1.4 is included in TYPO3 v7.6 Have a look at the dsource of your backend, jquery is included here: typo3/sysext/core/Resources/Public/JavaScript/Contrib/jquery/

And this is how to include your own BE js file:
https://docs.typo3.org/typo3cms/InsideTypo3Reference/CoreArchitecture/BackendModules/BackendModuleApi/Index.html#tbe-modules

$GLOBALS['TBE_MODULES']['_configuration'][$_EXTKEY] = array (
    'jsFiles' => array (
        'EXT:' . $_EXTKEY . '/Resources/Public/Javascript/be-script.js',
    ),
);

However, if you want to include the coresponding js for your own BE module, it is best to load js & css in your fluid template via:
https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Be/Container.html#addjsfile

<f:be.container addJsFile="{f:uri.resource(path:'js/custom.js')}">
something
</f:be.container>

HTH.

Upvotes: 3

Related Questions