Ajax in layout?

Hai frnds,
Can we add ajax functionality in a layout?
I was wondering if someone has an answer for that. In my layout current
time is displayed.But if the time needs to be updated we have to refresh
the page.I want it using ajax.

Thanks,
Veena

Hai Anthony,
I didn’t get the ajax part working.Ths is my code.Can you plz help
me…

layout (home.html.erb)

<%= @time %>

<%= observe_field :time_div, :url => {:controller=>"home",:action => :show_time },:frequency => 0.25, :update => :time_div %>

Controller

class HomeController < ApplicationController
def show_time
@time=Time.now
render :partial => “time”, :object => @time
end

views/home/_time.html.erb

<%= @time %>

Thanks,
Veena

<%= observe_field :suggest, :url => { :action => :find_suggestion },
:frequency => 0.25,
:update => :suggest,
:with => ‘q’
%>
it will refresh the id “suggest”

if you cann’t understand
you can also find observe_field method

2010/4/9 Veena J. [email protected]

Veena,

try periodically call remote instead of observer field.

Thanks,
Bala

Thanks Bala…
periodically call remote worked for me

Thank You very much,
Veena