David
2009-Mar-12 21:00 UTC
using instance variable within JavaScript function loaded in a partial
Im wondering, how do I go about allowing my javascript function to
load the updated instance variable that is loaded within a partial?
To be specific, I have a javascript function call:
onmousedown="changeTab(this)" for a tab in my layout. This function
passes an instance variable with an Ajax.Request like so:
changeTab(tab) {
new Ajax.Request( ''/test/ajax'', {parameters: { date:
<%array_or_string_for_javascript(@date) %> })
}
@date is changed each time a different link_to_remote is called and
the link_to_remote catches this change and send the updated @date
variable, but my javascript function changeTab does not pass the
updated @date variable. How do I get the changeTab javascript
function to pass the new updated @date variable?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Mar-12 22:26 UTC
Re: using instance variable within JavaScript function loaded in a partial
On Mar 12, 9:00 pm, David <dly...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Im wondering, how do I go about allowing my javascript function to > load the updated instance variable that is loaded within a partial? > To be specific, I have a javascript function call: > onmousedown="changeTab(this)" for a tab in my layout. This function > passes an instance variable with an Ajax.Request like so: > > changeTab(tab) { > new Ajax.Request( ''/test/ajax'', {parameters: { date: <%> array_or_string_for_javascript(@date) %> }) > > }This code is only evaluated once so what happens is normal. One way of doing things is to have the date be a parameter of changeTab (assuming that whatever calls changeTab is updated after these requests). Another is to have your requests update some global javascript variable Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---