# Manipulation of javascript object via RJS

**URL:** <https://www.ruby-forum.com/t/manipulation-of-javascript-object-via-rjs/104423>\
**Category:** Rails\
**Created:** [May 17, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/manipulation-of-javascript-object-via-rjs/104423 "2007-05-17T20:31:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@luca](https://www.ruby-forum.com/u/luca)\
**Post date:** [May 17, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/manipulation-of-javascript-object-via-rjs/104423/1 "2007-05-17T20:31:28Z")

</div>

Hi All

I would like to manipulate a javascript object which I’ve created as  
follows:

… HTML stuff… here

This object is used to manage the page (like replace DIVs depending on  
the actions of the user)  
So, what I would like to do with this object from within the RJS is to  
change values and add functions.  
For example, what I’ve tested (but didn’t work) is

page.myJSobject.varname = 10

Any suggestions ?

Thnx  
LuCa

---

<div class="post-metadata">

**Author:** ![luca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/51bf81/32.png) [@luca](https://www.ruby-forum.com/u/luca)\
**Post date:** [May 17, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/manipulation-of-javascript-object-via-rjs/104423/2 "2007-05-17T21:30:05Z")

</div>

After some research I found:

page \<\< “myJSobject.newfunc = function() { alert(“value is…” }”

LuCa
