0

I would like to place some ColdFusion code into a javascript variable. Please could someone advise how this can be done.

The ColdFushion code is as follows:

#LabelOverride::get('person')#
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Coder
  • 809
  • 1
  • 10
  • 23
  • 1
    Just curious what the double colon `::` operator is. Is that new to ColdFusion? – user12031119 Oct 29 '19 at 14:10
  • 1
    Looks like someone is trying to do a Bind operation. See: https://stackoverflow.com/questions/1520360/what-does-double-colon-do-in-javascript/31180878 . If this is the intent, then no, ColdFusion does not work this way. – James A Mohler Oct 29 '19 at 17:11
  • 1
    @JamesAMohler Thanks. While the answer given by Sev Roberts is correct given the way the question was worded, it certainly will not work. – user12031119 Oct 29 '19 at 22:47

1 Answers1

4

A literal answer to your question would be something like:

<script>
var myJsVariable = '#EncodeForJavascript(LabelOverride::get("person"))#';
</script>

But if you're asking this question, I think there's a chance it's not going to behave quite how you might be hoping.

Sev Roberts
  • 1,295
  • 6
  • 7