![](/img/trans.png)
[英]How to display a picture using Fluid (ViewHelper) from a JavaScript-file in TYPO3
[英]How to use a Javascript variable as argument in Fluid URI ViewHelper
我想从Fluid模板发出Ajax调用,并且要使用Fluid URI操作ViewHelper 。 问题在于,其中一个参数动态地来自Javascript变量。 如何实现由Fluid渲染ViewHelper并在运行时插入Javascript变量的内容?
这是我的代码(简体):
function test(field) {
xmlhttp.open("GET", '<f:uri.action action="ajax" arguments="{filterfield:' + field + '}" />', true);
}
当前,流体渲染输出为:
function test(field) {
xmlhttp.open("GET",'mod.php?...&tx_test_test_testview%5Bfilterfield%5D=%20%2B%20field%20%2B%20...', true);
}
但是我想实现:
function test(field) {
xmlhttp.open("GET",'mod.php?...&tx_test_test_testview%5Bfilterfield%5D=' + field + '...', true);
}
我把...
放在与输出无关的地方。
我认为您不能用流畅的方式确切地实现所需的功能,因为f:uri的viewhelpers最终会通过使用urlencode函数的typolink方法传递。 也许最好在其中传递一些唯一的字符串并使用JS替换它? 例如这样的:
function test(field) {
xmlhttp.open("GET", '<f:uri.action action="ajax" arguments="{filterfield: '___FIELD___'}" />'.replace('___FIELD___', field), true);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.