Andreas Andreas - 6 months ago 47
Ajax Question

How to use a Javascript variable as argument in Fluid URI ViewHelper

I want to make an Ajax call out of a Fluid template and I want to use the Fluid URI action ViewHelper. The problem is, that one of the arguments comes dynamically from a Javascript variable. How can I achieve, that the ViewHelper is rendered by Fluid and the content of the Javascript variable is inserted on runtime?

Here is my code (simplified):

function test(field) {"GET", '<f:uri.action action="ajax" arguments="{filterfield:' + field + '}" />', true);

Currently the Fluid rendered output is:

function test(field) {"GET",'mod.php?...&tx_test_test_testview%5Bfilterfield%5D=%20%2B%20field%20%2B%20...', true);

But what I want to achieve:

function test(field) {"GET",'mod.php?...&tx_test_test_testview%5Bfilterfield%5D=' + field + '...', true);

I put
where the output is not relevant.

mrf mrf

I don't think you can achieve exactly what you want with fluid, because f:uri viewhelpers finally passes through typolink method, which uses urlencode function. Maybe it will be better to pass there some unique string and replace it using JS? For example like that:

function test(field) {"GET", '<f:uri.action action="ajax" arguments="{filterfield: '___FIELD___'}" />'.replace('___FIELD___', field), true);