Hi All
In my rhtml file I create a javascript object like
<SCRIPT>
function onLoad() {
js_obj = new Pkgname.ClassName(<%= my_tabs.to_json %>)
}
</SCRIPT>
This ''js_obj'' is the javascript object which use all the time
in this
page to hide/show/change stuff depending on the users actions. At some
point the user can click a button, which starts an AJAX
request(button_to_function), which will update, lets say, tab 3. This
means: I need to do the AJAX call and afterwards chnage to tab 3. I
hoped that I could access to ''js_obj'' in my .rjs file so I
could do
something like
page.js_obj.showTabByIndex(3)
This should change to tab 3, but doesn''t work. Hopefully I have the
syntax wrong, do I ?
If this is not possible is there a way I can perform an action after the
ajax request is finished with a button_to_function request ?
Thx
LuCa
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thorsten
2007-Apr-09 15:54 UTC
Re: Is a javascript object accessible in the .rjs file (AJAX) ?
i may be wrong, but i think i read a couple of times that you can do this in an rjs file: page << "js_obj.showTabByIndex(3)" i think you can "feed" any JavaScript code into the page object like this, and it wll be sent back to the browser. could be wrong though, give it a try. On 9 Apr., 17:24, LuCa <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi All > > In my rhtml file I create a javascript object like > > <SCRIPT> > function onLoad() { > js_obj = new Pkgname.ClassName(<%= my_tabs.to_json %>) > } > </SCRIPT> > > This ''js_obj'' is the javascript object which use all the time in this > page to hide/show/change stuff depending on the users actions. At some > point the user can click a button, which starts an AJAX > request(button_to_function), which will update, lets say, tab 3. This > means: I need to do the AJAX call and afterwards chnage to tab 3. I > hoped that I could access to ''js_obj'' in my .rjs file so I could do > something like > > page.js_obj.showTabByIndex(3) > > This should change to tab 3, but doesn''t work. Hopefully I have the > syntax wrong, do I ? > > If this is not possible is there a way I can perform an action after the > ajax request is finished with a button_to_function request ? > > Thx > LuCa > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that works perfect, thnx
Just for those interested, I noticed that the same thing can also be
done using
:complte => "js_obj.show......."
inside the button_to_function call (this is on the client side)
LuCa
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---