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| %> <fieldset id="date-range"><legend>Date Range</legend> <%= 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'' %> </fieldset> <%end%> <div id ="myDiv"> <table class ="list"> <tr> <th align="center" style="width:5%"><%=("Name")%></th> <th align="center" style="width:12%"><%=("Subject")%></th> </thead> </tr> <% if @rpt != nil then %> <% if @rpt.length > 0 then %> <%i=0%> <% for rpts in @rpt %> <tr> <td align="center" style="width:5%"><%= @rpt[i].NAME %></font></font></td> <td align="center" style="width:12%"><%= @rpt[i].SUBJECT %></font></td> <% i =i+1%> </tr> <%end%> <% else %> <tr><td No data to show in this view.</td></tr> <% end %> <% end %> </table> </div> -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-May-11 13:46 UTC
Re: Page refreshed as a whole instead of a specific element.
On May 11, 2:07 pm, Najam Alvi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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> I have following code in my form.html.erb . > > Please help me out. > > Thanks > > <%= javascript_include_tag "prototype" %> > > <%form_for :reporttype do |f| %> > <fieldset id="date-range"><legend>Date Range</legend> > <%= 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'' %> > </fieldset> > <%end%> > > <div id ="myDiv"> > <table class ="list"> > <tr> > > <th align="center" style="width:5%"><%=("Name")%></th> > > <th align="center" style="width:12%"><%=("Subject")%></th> > > </thead> > </tr> > <% if @rpt != nil then %> > <% if @rpt.length > 0 then %> > <%i=0%> > <% for rpts in @rpt %> > <tr> > <td align="center" style="width:5%"><%= @rpt[i].NAME > %></font></font></td> > <td align="center" style="width:12%"><%= @rpt[i].SUBJECT %></font></td> > <% i =i+1%> > </tr> > <%end%> > <% else %> > <tr><td No data to show in this view.</td></tr> > <% end %> > <% end %> > </table> > </div> > -- > Posted viahttp://www.ruby-forum.com/.
Colin Law
2009-May-11 15:42 UTC
Re: Page refreshed as a whole instead of a specific element.
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 Alvi <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > 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| %> > <fieldset id="date-range"><legend>Date Range</legend> > <%= 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'' %> > </fieldset> > <%end%> > > <div id ="myDiv"> > <table class ="list"> > <tr> > > <th align="center" style="width:5%"><%=("Name")%></th> > > <th align="center" style="width:12%"><%=("Subject")%></th> > > </thead> > </tr> > <% if @rpt != nil then %> > <% if @rpt.length > 0 then %> > <%i=0%> > <% for rpts in @rpt %> > <tr> > <td align="center" style="width:5%"><%= @rpt[i].NAME > %></font></font></td> > <td align="center" style="width:12%"><%= @rpt[i].SUBJECT %></font></td> > <% i =i+1%> > </tr> > <%end%> > <% else %> > <tr><td No data to show in this view.</td></tr> > <% end %> > <% end %> > </table> > </div> > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2009-May-11 16:12 UTC
Re: Page refreshed as a whole instead of a specific element.
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 On May 11, 2009, at 11:42 AM, Colin Law wrote:> 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 Alvi <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > 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| %> > <fieldset id="date-range"><legend>Date Range</legend> > <%= 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'' %> > </fieldset> > <%end%> > > <div id ="myDiv"> > <table class ="list"> > <tr> > > <th align="center" style="width:5%"><%=("Name")%></th> > > <th align="center" style="width:12%"><%=("Subject")%></th> > > </thead> > </tr> > <% if @rpt != nil then %> > <% if @rpt.length > 0 then %> > <%i=0%> > <% for rpts in @rpt %> > <tr> > <td align="center" style="width:5%"><%= @rpt[i].NAME > %></font></font></td> > <td align="center" style="width:12%"><%= @rpt[i].SUBJECT %></font></ > td> > <% i =i+1%> > </tr> > <%end%> > <% else %> > <tr><td No data to show in this view.</td></tr> > <% end %> > <% end %> > </table> > </div> > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---