Thomas Allen
2009-Jul-20 19:55 UTC
AJAX "render :partial" does not update if specified view matches current view
I have some simple code that renders a form to an element specified in form_remote_tag :update. The problem is that, if the loaded view matches the view to render, Rails does nothing rather than refreshing the view (which is the desired behavior). There is an element with id "form," also specified in the form tag: <div id="form" class="tab-content"></div> Here''s how the form is built: <% form_remote_tag( :url => { :action => ''create'', :id => params[:id] }, :update => ''form'' ) do -%> The exit code in this controller action: when ''Save'' render :partial => ''edit'' when ''Save and New'' render :partial => ''new'' The view that contains this form is the "new" partial. So, the idea is that if a user clicks "Save and New" they will have the "new" view refreshed rather than being moved to the edit screen. Is what I''m attempting possible with render :partial? Thomas
Thomas Allen
2009-Jul-22 12:51 UTC
Re: AJAX "render :partial" does not update if specified view matches current view
Is what I''m attempting possible with render :partial? On Jul 20, 3:55 pm, Thomas Allen <thomasmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have some simple code that renders a form to an element specified in > form_remote_tag :update. The problem is that, if the loaded view > matches the view to render, Rails does nothing rather than refreshing > the view (which is the desired behavior). > > There is an element with id "form," also specified in the form tag: > > <div id="form" class="tab-content"></div> > > Here''s how the form is built: > > <% form_remote_tag( > :url => { > :action => ''create'', > :id => params[:id] > }, > :update => ''form'' > ) do -%> > > The exit code in this controller action: > > when ''Save'' > render :partial => ''edit'' > when ''Save and New'' > render :partial => ''new'' > > The view that contains this form is the "new" partial. So, the idea is > that if a user clicks "Save and New" they will have the "new" view > refreshed rather than being moved to the edit screen. > > Is what I''m attempting possible with render :partial? > > Thomas
Frederick Cheung
2009-Jul-22 13:02 UTC
Re: AJAX "render :partial" does not update if specified view matches current view
On Jul 22, 1:51 pm, Thomas Allen <thomasmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is what I''m attempting possible with render :partial? >Have you checked with firebug to see what is actually going back and forth between the browser and the server ? (fun issues like the browser helpfully autocompleteing the new fields for you ?) Fred> On Jul 20, 3:55 pm, Thomas Allen <thomasmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I have some simple code that renders a form to an element specified in > > form_remote_tag :update. The problem is that, if the loaded view > > matches the view to render, Rails does nothing rather than refreshing > > the view (which is the desired behavior). > > > There is an element with id "form," also specified in the form tag: > > > <div id="form" class="tab-content"></div> > > > Here''s how the form is built: > > > <% form_remote_tag( > > :url => { > > :action => ''create'', > > :id => params[:id] > > }, > > :update => ''form'' > > ) do -%> > > > The exit code in this controller action: > > > when ''Save'' > > render :partial => ''edit'' > > when ''Save and New'' > > render :partial => ''new'' > > > The view that contains this form is the "new" partial. So, the idea is > > that if a user clicks "Save and New" they will have the "new" view > > refreshed rather than being moved to the edit screen. > > > Is what I''m attempting possible with render :partial? > > > Thomas
Thomas Allen
2009-Jul-22 14:22 UTC
Re: AJAX "render :partial" does not update if specified view matches current view
Hm, I''ll try explicitly setting the [nonstandard] autocomplete attribute off in the inputs... Thomas On Jul 22, 9:02 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 22, 1:51 pm, Thomas Allen <thomasmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is what I''m attempting possible with render :partial? > > Have you checked with firebug to see what is actually going back and > forth between the browser and the server ? (fun issues like the > browser helpfully autocompleteing the new fields for you ?) > > Fred > > > On Jul 20, 3:55 pm, Thomas Allen <thomasmal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have some simple code that renders a form to an element specified in > > > form_remote_tag :update. The problem is that, if the loaded view > > > matches the view to render, Rails does nothing rather than refreshing > > > the view (which is the desired behavior). > > > > There is an element with id "form," also specified in the form tag: > > > > <div id="form" class="tab-content"></div> > > > > Here''s how the form is built: > > > > <% form_remote_tag( > > > :url => { > > > :action => ''create'', > > > :id => params[:id] > > > }, > > > :update => ''form'' > > > ) do -%> > > > > The exit code in this controller action: > > > > when ''Save'' > > > render :partial => ''edit'' > > > when ''Save and New'' > > > render :partial => ''new'' > > > > The view that contains this form is the "new" partial. So, the idea is > > > that if a user clicks "Save and New" they will have the "new" view > > > refreshed rather than being moved to the edit screen. > > > > Is what I''m attempting possible with render :partial? > > > > Thomas