php - 在 TYPO3 后端添加 jQuery 函数
问题描述
当我打开“页面”视图时,我需要在我的 TYPO3 后端自定义 jQuery 函数。
我为 preProcess 添加了一个钩子
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']
['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']
['tx_dashboard'] =
\vendor\dashboard\Hooks\Backend\IconCorrection::class;
在我的 IconCorrection 中我添加了
public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
{
GeneralUtility::makeInstance(PageRenderer::class)
->addRequireJsConfiguration([
'paths' => [
'iconCorrection'=>'/typo3conf/ext/dashboard/Resources/Public/JavaScript/hidePreviewIcon.js',
],
'shim' => [
'iconCorrection' => ['jquery'],
],
]);
}
}
在我的 hidePreviewIcon.js 我有一个 console.log 我想要类似的东西,$(".btn").hide();
但现在只是测试 js 是否已加载。
在我的开发工具中,我看到 js 已加载,但未执行 console.log。
我缺少什么?我可以
使用 TYPO3 v8.7.2addJsFile
而不是ImaddRequireJsConfiguration
编辑:
我添加了
$renderer =\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$renderer->addJsFile('/typo3conf/ext/trumpf_editordashboard/Resources/Public/JavaScript/hidePreviewIcon.js', 'text/javascript', false, false, '', true, '|', false, '');
到我的preProcess()
功能。
现在 .js 已加载并执行 console.log(); 但我的
$(document).ready(){$(".btn").hide();
不工作。我认为它执行得太早了
编辑2:诀窍:
$(function(){
$('#typo3-contentIframe').ready(function(){
console.log("loaded");
$(".btn").hide();
});
});
解决方案
推荐阅读
- flutter - 如何在 Flutter 中将 AlertDialog FlatButton 居中
- c++ - C++ 需要用于检查函数签名的表达式不适用于 Lambda 或 gcc 中的成员函数
- android - ADB over TCP/IP 在没有连接 USB 电缆的情况下无法工作
- typescript - 如何确保只有在 Typescript 中完成另一个方法后才执行一个方法?
- ansible - ansible - 将字符串附加到存储在变量中的每个列表项
- python - PySpark RDD MapPartition 转换
- apache-spark - 从 sql server 读取数据并在 PySpark 中使用特殊字符传递我的密码
- metadata - ID3v2 文档在哪里?
- javascript - ComponentDidMount 等不按顺序触发功能
- angular - 角度 8,如何在自定义包中存储静态 HTML 文件?