You need to sign in to do that
Don't have an account?
generate dynamic javascript
Hi,
I've an app in 3 languages for which I've a translation apex class.
In my VF page, i use some javascript to display a modal (bootstrap) to let the user confirming his choice without calling the apex, so as to limit the number of calls.
My issue is i want to display the confirm screen in the language of the user.
I've tried to generate the javascript with some <apex:outputText > in it or simply {!mylabel} but it doesn't work.
<script type="text/javascript"> var arrChoices = new Array(); var arrNames = new Array(); alert('<apex:outputText>{!labels.Title_Col1_Conf__c}</apex:outputText>'); alert('{!labels.Title_Col1_Conf__c}'); .... </script>
the alerts are empty.
I could make a remote invokeAction to get the labels in the correct language, but it seems a little overpowered for that.
Is there a simple way to do that ?
Thanks for the help
Ced
What is labels? Is that a single instance of an object or an array (list)?
labels is an instance of an object HR07_Trans__c (custom settings) containing all the translations.
I'd expect that to work then. The merge fields will be replaced before the page is rendered, so the javascript alerts should just contain the string literals. I assume if you view the source of the page then these are empty? Have you checked that the user has access to these fields via Field Level Security?
ok, that's what i thought, it should work.
... and by checking my code once again i saw I made a wrong copy/paste of the field name ...
sorry to make you having lost your time Bob :-(