On Thu, Jan 7, 2010 at 9:45 AM, nisha <nisha0...@gmail.com> 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
>
>
If you're trying to access server-side Ruby objects within the client-side
Javascript, then this is possible by
making an Ajax call to the server and returning the result as JSON or some
other formatted data.

If you're trying to access server-side Ruby objects within the HTML, then
you can simply do the following:

<%= @object.attribute %>

Good luck,

-Conrad


> --
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com>
> .
> 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-t...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to