Hi all, TestController def show @object = Object.find(params[:id]) end I have show.html.erb which has the foll js in the head <script type=''text/javascript''> $(document).ready(function($) { $("#divcontainer").load("first.html.erb"); var refreshId1 = setInterval(function() {$("#divcontainer").load (''first.html.erb'');}, 120000); }) </script> This basically dynamically loads the first.html file after the set interval... The first.html.erb is as follows script type=''text/javascript''> $(document).ready(function($) { //how to access @object.attribute? }) </script> <div class=''test''></div> Can anyone pls guide me how to access @object.attribute in first.html.erb''s js to load the html in the container. Pls help -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Narendra Kumar Payidiparthi
2010-Jan-08 16:46 UTC
Re: Javascript to access a server side element in rails
nisha, Did you try with <% %> or <%= %> tags in the html.erb. Something like <%= @object.attribute %> I am not sure , what problem you are facing? Regards, Naren On Thu, Jan 7, 2010 at 9:45 AM, nisha <nisha0609-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > TestController > > def show > @object = Object.find(params[:id]) > end > > I have show.html.erb which has the foll js in the head > > <script type=''text/javascript''> > $(document).ready(function($) > { > $("#divcontainer").load("first.html.erb"); > var refreshId1 = setInterval(function() > {$("#divcontainer").load > (''first.html.erb'');}, 120000); > }) > </script> > > This basically dynamically loads the first.html file after the set > interval... > > The first.html.erb is as follows > > script type=''text/javascript''> > $(document).ready(function($) { > //how to access @object.attribute? > }) > </script> > <div class=''test''></div> > > > Can anyone pls guide me how to access @object.attribute in > first.html.erb''s js to load the html in the container. > > Pls help > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.