# How to use a $var in escape\_javascript

**URL:** <https://www.ruby-forum.com/t/how-to-use-a-var-in-escape-javascript/229312>\
**Category:** Rails\
**Created:** [February 1, 2013, 6:01am UTC](https://www.ruby-forum.com/t/how-to-use-a-var-in-escape-javascript/229312 "2013-02-01T06:01:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anush\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@anush\_j](https://www.ruby-forum.com/u/anush_j)\
**Post date:** [February 1, 2013, 6:01am UTC](https://www.ruby-forum.com/t/how-to-use-a-var-in-escape-javascript/229312/1 "2013-02-01T06:01:26Z")

</div>

Hi All,

A question on using javascript within a view to render a partial. Been  
struggling wit this for a bit.  
I’ve multiple partials in my views and I want to replace them within a  
specific div, how do I get this variable ‘page’ within the  
escape\_javascript and replace it with ‘reviews’ so I can render the  
other pages (Such as specials, gallery, etc) within that div.

Thanks. Appreciate the help!  
Below is the code snippet.

---

<div class="post-metadata">

**Author:** ![anush\_j](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@anush\_j](https://www.ruby-forum.com/u/anush_j)\
**Post date:** [February 1, 2013, 8:23am UTC](https://www.ruby-forum.com/t/how-to-use-a-var-in-escape-javascript/229312/2 "2013-02-01T08:23:55Z")

</div>

On Feb 1, 5:01am, “Anush J.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Below is the code snippet.  
> You can’t - the call to escape\_javascript happens server side, whereas  
> the value of page will only be known client side, at the point where  
> the user clicks on something. You could load the content via ajax

Fred
