I agree with Naren.

Sending name of the div - "current_reading" as the :update option in the
ajax call is enough to automatically replace the contents. No need for
explicitly calling replace_html in the action.

However if you want to use replace_html in your action...

do not send <%= periodically_call_remote(:url => { :action=>
:show_current_readings
}, :frequency => 5, :update =>"current_reading")%>

:update=>"current_reading"

good luck,
Nitin.



On Wed, Mar 17, 2010 at 12:16 PM, Narendra sisodiya <
[email protected]> wrote:

> Hi Veena,
>
> You are mentioning :update attribute in the ajax call, so in the responding
> action you do not need to replace the content of the div. Rails will
> automatically update it.
>
> use following code in your controller
>
>      render :partial=>'current_readings_list'
>
> or the second solution is just remove the :update attribute from the ajax
> call it will run properly.
>
> ~Naren
>
>
>>
>
> On Wed, Mar 17, 2010 at 11:53 AM, Veena Jose <[email protected]> wrote:
>
>> Hai Robert,
>> Thanks for your help.I have done what you have told me.But the problem
>> is it refreshes only for the first time and shows some RJSerror on the
>> webpage.
>>
>> readings controller
>>
>> def show_current_readings
>>   @range=ConfigureParameter.find(:all)
>>    if (params[:state] =="")
>>      @readings = CurrentReading.find(:all)
>>    else
>>    stations = Station.find_all_by_state(params[:state])
>>    @readings=
>> CurrentReading.find_all_by_station_id(stations,:order=>"station_id")
>>    end
>>    render :update do |page|
>>      page.replace_html :current_reading,
>> :partial=>'current_readings_list'
>>    end
>>  end
>>
>>
>> readings/index.html.erb
>>
>> <% form_for :selected_district ,:url => {:action =>'update',:id =>
>> @selected_district } do |f| %>
>>   <center><b> <%= f.label :Stations  %></b>
>> <%= select(:selected_district,:state,
>> @states,{:include_blank=>'All'},{:onchange
>> =>remote_function(:url=>"/readings/show_readings_for_station",:with
>> =>"'state='+this.value")} )  %> </center>
>> <%end%>
>>
>> <div id="reading_list">
>>  <% form_tag  :action =>"details" do %>
>>  <div id="current_reading">
>>   #code here
>>  </div>
>> <%= periodically_call_remote(:url => { :action=> :show_current_readings
>> }, :frequency => 5, :update =>"current_reading")%>
>> </div>
>>
>> _current_readings_list.html.erb
>>
>> #this partial has the code which is inside the "current_reading" div tag
>>
>> I am attaching the error generated on the webpage also.
>>
>> Please help me
>>
>>
>> Thanks
>> veena
>>
>>
>>
>> Attachments:
>> http://www.ruby-forum.com/attachment/4591/1.rar
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> --
>> 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<rubyonrails-talk%[email protected]>
>> .
>> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to