Message from discussion
Adding a delete confirmation
MIME-Version: 1.0
Message-ID: <36189a9b-c116-48e2-bc48-a01bd2d24ae1@d70g2000hsb.googlegroups.com>
Date: Thu, 24 Jan 2008 22:05:27 -0800 (PST)
Received: by 10.100.153.6 with SMTP id a6mr16017ane.10.1201241127521; Thu, 24
Jan 2008 22:05:27 -0800 (PST)
In-Reply-To: <B8AC67E0-9EE3-4543-A8F3-E941CDB8B978@jlaine.net>
X-IP: 71.139.188.142
References: <8ced4378-7ea2-43f2-9ac8-05b4ad3ea287@x69g2000hsx.googlegroups.com>
<f58d8dcb0801241734l66d81ad2t5db054dc198bb089@mail.gmail.com>
<B8AC67E0-9EE3-4543-A8F3-E941CDB8B978@jlaine.net>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11)
Gecko/20071127 Firefox/2.0.0.11,gzip(gfe),gzip(gfe)
Subject: Re: Adding a delete confirmation
From: KJoyner <K...@kjoyner.com>
To: Low Pro <low-pro@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Jarkko is correct, I am trying to create both an accessible link (when
Javascript is disabled) and an AJAX request when java is enabled.
After reading your post, I just thought to check my log to see if it
showed anything. It does route but shows an
ActionController::InvalidAuthenticityToken during a call to
request_forgery_protection.
On 24 Jan, 21:40, Jarkko Laine <jar...@jlaine.net> wrote:
> On 25.1.2008, at 3.34, Matt Aimonetti wrote:
>
> > Remote.DeleteLink = Behavior.create(Remote.Base, {
> > onclick : function() {
> > var options = Object.extend({ url : this.element.href, method :
> > 'delete' }, this.options);
> > if (confirm('Are you sure?')){
> > return this._makeRequest(options);
> > }else{
> > return false;
> > }
> > }
> > });
>
> > don't change your route, a delete action should not be a GET but a
> > DELETE.
>
> I think he's using the delete action (note the name) as an
> intermediary action to hold a form with DELETE method pointing to the
> _destroy_ action that actually deletes the record. That's pretty much
> the only way to use an accessible link to perform a destructive action
> afaik.
>
>
>
> > On 1/24/08, KJoyner <K...@kjoyner.com> wrote:
> > <snip>
> > Remote.Delete = Behavior.create( Remote.Base, {
> > onclick: function( event ) {
> > if ( confirm( 'Are you sure?' ) ) {
> > var destroy_url = this.element.href.gsub ( '/delete$', '' );
> > options = Object.extend( { url: destroy_url, method: 'delete' },
> > this.options );
> > return this._makeRequest( options )
> > }
> > return false;
> > }
> > });
>
> > Event.addBehavior( {
> > '.delete' : Remote.Delete
> > });
>
> > The onclick gets executed but it is not working correctly. Any help
> > would be appriciated.
>
> So what happens? Does the request get to Rails? Have you used Firebug
> to debug what happens inside the behaviour (e.g. what does options
> look like when you make the request)?
>
> --