Solved

Having trouble escaping variables in javascript

Posted on 2010-11-16
1
204 Views
Last Modified: 2012-05-10
I have the below javascript snippet: #url.typ# and #url.dept# are coldfusion variable on my site.  Some of the variables have an apostrophe in them, ex. men's   Can I escape them inside this snippet somehow?
<script type='text/javascript'>

product.Catalog.init({

    filters: {

        category: ['#url.typ#'],

        department: ['#url.dept#']

    },

    maxFacetOptions: 10

});

</script>

Open in new window

0
Comment
Question by:rkoechel
1 Comment
 
LVL 16

Accepted Solution

by:
jmatix earned 500 total points
ID: 34151378
If you need to escape only apostrophies (not worried about double quotes (") in those values),  then you can use double quotes to surround the JS values as:

<script type='text/javascript'>

product.Catalog.init({

    filters: {

        category: ["#url.typ#"],

        department: ["#url.dept#"]

    },

    maxFacetOptions: 10

});

</script>

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Coldfusion RegEx 8 49
css, html 6 31
Fire Fox doesn't show calendar on html page ? 5 47
Update cached table in H2 database 6 11
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now