# Page refreshed as a whole instead of a specific element

**URL:** <https://www.ruby-forum.com/t/page-refreshed-as-a-whole-instead-of-a-specific-element/167683>\
**Category:** Rails\
**Created:** [May 11, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/page-refreshed-as-a-whole-instead-of-a-specific-element/167683 "2009-05-11T15:07:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![najam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7feea3/32.png) [@najam](https://www.ruby-forum.com/u/najam)\
**Post date:** [May 11, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/page-refreshed-as-a-whole-instead-of-a-specific-element/167683/1 "2009-05-11T15:07:57Z")

</div>

I am a new one to rails. I have a problem with link\_to\_remote.  
I have a calenedar on my web page, user selects a date and controllers  
returns a report related to that specific date. The whole process is  
working except one thing, instead of only myDiv the whole page is  
refreshed. The header menu is reappeared in the myDive tag.

I have following code in my form.html.erb .

Please help me out.

Thanks

\<%= javascript\_include\_tag “prototype” %\>

\<%form\_for :reporttype do |f| %\>

 Date Range \<%= f.text\_field 'date\_from', :id =\> 'txtdate', :size =\> 10 , :value =\> @form%\>\<%= calendar\_for('txtdate') %\> \<%= link\_to\_remote l(:button\_apply), { :update =\> 'myDiv', :url =\> {:action =\> 'display', :id =\> params[:id]}, :with =\> "'seldate=' +$F('txtdate')", }, :class =\> 'icon icon-checked' %\> \<%end%\>
 \<% if @rpt != nil then %\> \<% if @rpt.length \> 0 then %\> \<%i=0%\> \<% for rpts in @rpt %\> \<% i =i+1%\> \<%end%\> \<% else %\> \<td No data to show in this view. \<% end %\> \<% end %\>

| \<%=("Name")%\> | \<%=("Subject")%\> |
| --- | --- |
| \<%= @rpt[i].NAME %\> | \<%= @rpt[i].SUBJECT %\> |
|
| |

---

<div class="post-metadata">

**Author:** ![najam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7feea3/32.png) [@najam](https://www.ruby-forum.com/u/najam)\
**Post date:** [May 11, 2009, 3:46pm UTC](https://www.ruby-forum.com/t/page-refreshed-as-a-whole-instead-of-a-specific-element/167683/2 "2009-05-11T15:46:51Z")

</div>

On May 11, 2:07 pm, Najam A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I am a new one to rails. I have a problem with link\_to\_remote.  
> I have a calenedar on my web page, user selects a date and controllers  
> returns a report related to that specific date. The whole process is  
> working except one thing, instead of only myDiv the whole page is  
> refreshed. The header menu is reappeared in the myDive tag.

sounds like your display action is rendering too much

Fred

---

<div class="post-metadata">

**Author:** ![najam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7feea3/32.png) [@najam](https://www.ruby-forum.com/u/najam)\
**Post date:** [May 11, 2009, 5:43pm UTC](https://www.ruby-forum.com/t/page-refreshed-as-a-whole-instead-of-a-specific-element/167683/3 "2009-05-11T17:43:13Z")

</div>

The controller action must only render the new content for the div, it  
seems  
that it is sending the whole page again, appearing inside the div.

2009/5/11 Najam A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![najam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7feea3/32.png) [@najam](https://www.ruby-forum.com/u/najam)\
**Post date:** [May 11, 2009, 6:13pm UTC](https://www.ruby-forum.com/t/page-refreshed-as-a-whole-instead-of-a-specific-element/167683/4 "2009-05-11T18:13:58Z")

</div>

You haven’t shown the code in the controller that responds to the  
‘display’ action, but I suspect that you need to add “:layout =\>  
false” to the render (or make the render explicit rather than the  
default after hitting the end of the display action without having  
rendered or redirected).  
-Rob
