Search code examples
jqueryjquery-uicoldfusionjquery-ui-slider

How do you output a Coldfusion variable within jquery script?


In coldfusion I have this part of the jquery ui slider script:

$("#slider-range_sun").slider({
   range: true,
   min: 0,
   max: 1440,
   step: 15,
   values: [375, 1020],

The last line where it says values: [375, 1020] I need to set the numbers with coldfusion variables that are coming from the DB. Putting cfoutput around that line and outputting the variables with pound signs breaks the jquery. Any thoughts on how to do this?


Solution

  • If this is all just inline JavaScript in a CFM file, you can do this to avoid the jQuery selector entirely:

    $("#slider-range_sun").slider({
        range: true,
        min: 0,
        max: 1440,
        step: 15,
        values: <cfoutput>[#variableA#, #variableB#]</cfoutput>,