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 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
<%= 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
Hai Anthony, I didn't get the ajax part working.Ths is my code.Can you plz help me....
layout (home.html.erb) ...................... <div id="time_div"><h4 align="right"><%= @time %></h4></div> <%= 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 .......................... <h4 align="right"><%= @time %></h4>
Thanks, Veena
Veena,
try periodically call remote instead of observer field.
Thanks, Bala
Thanks Bala...... periodically call remote worked for me
Thank You very much, Veena