# Using page variables in rjs templates

**URL:** <https://www.ruby-forum.com/t/using-page-variables-in-rjs-templates/119409>\
**Category:** Rails\
**Created:** [November 6, 2007, 8:02pm UTC](https://www.ruby-forum.com/t/using-page-variables-in-rjs-templates/119409 "2007-11-06T20:02:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magic\_hat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5daacb/32.png) [@magic\_hat](https://www.ruby-forum.com/u/magic_hat)\
**Post date:** [November 6, 2007, 8:02pm UTC](https://www.ruby-forum.com/t/using-page-variables-in-rjs-templates/119409/1 "2007-11-06T20:02:56Z")

</div>

Hi everyone.

I have a CMS that uses a fckeditor-like WSIWYG setup. I’m writing an  
ajax action that toggles the view between WSIWYG and a textarea that  
shows the actual html.

To do that, I need to pull the existing content out of an iframe on  
the page and reinsert it into the textarea.

page.assign(@content, $(‘edit’).contentWindow.document.body.innerHTML)

page.replace\_html “texteditor”, ‘"#{@content}" \</  
textarea\>’

It’s giving me syntax errors on the $(‘edit’) line, and I’m not at all  
convinced that page.assign is what I’m looking for.

Help?

---

<div class="post-metadata">

**Author:** ![magic\_hat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5daacb/32.png) [@magic\_hat](https://www.ruby-forum.com/u/magic_hat)\
**Post date:** [November 6, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/using-page-variables-in-rjs-templates/119409/2 "2007-11-06T20:50:39Z")

</div>

not to sure. but there are 2 points to keep in mind.

1. the DOM is not cross browser compatible  
ie. innerHTML is deprecated and does not work in ie6  
so use prototype Event.update  
or JQuery (its not rjs but it could probable provide a graceful fix)

2. Ajax is communicating with the server. Your just doing DOM  
manipulation.

Sorry, I couldn’t be more help. When you figure it out please post the  
solution I plan to add similar functionality to an app of my own.
