Hi Frederick,
>format doesn't actually help you here: the ajax request is genuinely
> requesting html. What you can do is
>
> if xhr?
> ...
> end
what i should write if xhr? is true?
something like:
render :partial =>show, :id => @sample
if i write that the def show is not call, neither show.js.rjs.
thanks
On Sep 10, 8:59 am, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On 10 Sep 2008, at 15:55, da991319 wrote:
>
>
>
> > Hi Robert,
>
> > I indeed did try with format.js. It occurs an error: template is
> > missing, Missing template samples/update.js.erb.
>
> > as I say i already have a show template and show.js.rjs that is doing
> > everything necessary if def show is called by an AJAX request. that
> > why i would like to call def show via an xmlhttprequest but from def
> > update in the controller ( i am not sure i am really clear) and i
> > think that is what xml_http_request is supposed to do (but i can be
> > wrong as i am new to AJAX and co).
>
> format doesn't actually help you here: the ajax request is genuinely
> requesting html. What you can do is
>
> if xhr?
> ...
> end
> (xhr? is an alias for xml_http_request?)
>
> which can tell if the request was submitted by prototype.
>
> Fred
>
>
>
> > On Sep 10, 8:40 am, Robert Walker <[EMAIL PROTECTED]>
> > wrote:
> >>> if @sample.update_attributes(params[:sample])
> >>> flash[:notice] = 'Sample was successfully updated.'
> >>> respond_to do |format|
> >>> format.html {redirect_to(@sample)}
> >>> format.js
> >>> end
> >>> else
> >>> render :action => "edit"
> >>> end
>
> >> Oops, I take this back. It should be more like:
>
> >> # PUT /people/1
> >> # PUT /people/1.xml
> >> def update
> >> @person = Person.find(params[:id])
>
> >> respond_to do |format|
> >> if @person.update_attributes(params[:person])
> >> flash[:notice] = 'Person was successfully updated.'
> >> format.html { redirect_to(@person) }
> >> format.js
> >> format.xml { head :ok }
> >> else
> >> format.html { render :action => "edit" }
> >> format.xml { render :xml => @person.errors, :status =>
> >> :unprocessable_entity }
> >> end
> >> end
> >> end
>
> >> I don't know where my head was on that previous post. Sorry about
> >> that...
> >> --
> >> Posted viahttp://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]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---