Forum: Ruby on Rails manipulation of javascript object via RJS

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ad745a3a6bdc249a7b34a0b6f5c8d5ec?d=identicon&s=25 LuCa (Guest)
on 2007-05-17 20:31
Hi All

I would like to manipulate a javascript object which I've created as

    function onLoad() {
        myJSobject = new MyClassName.Init(10,20, <%= ruby_arr.to_json
.... 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 ?

Ad745a3a6bdc249a7b34a0b6f5c8d5ec?d=identicon&s=25 LuCa (Guest)
on 2007-05-17 21:30
After some research I found:

page <<  "myJSobject.newfunc = function() { alert(\"value is....\" }"

This topic is locked and can not be replied to.