Message from discussion
Adding a delete confirmation
Received: by 10.114.60.19 with SMTP id i19mr28510waa.10.1201239633566;
Thu, 24 Jan 2008 21:40:33 -0800 (PST)
Return-Path: <jarks...@gmail.com>
Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174])
by mx.google.com with ESMTP id k36si606267waf.0.2008.01.24.21.40.31;
Thu, 24 Jan 2008 21:40:33 -0800 (PST)
Received-SPF: pass (google.com: domain of jarks...@gmail.com designates 66.249.92.174 as permitted sender) client-ip=66.249.92.174;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of jarks...@gmail.com designates 66.249.92.174 as permitted sender) smtp.mail=jarks...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by ug-out-1314.google.com with SMTP id a2so466574ugf.48
for <low-pro@googlegroups.com>; Thu, 24 Jan 2008 21:40:28 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:received:received:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender;
bh=NP7ydyVNb0i21NSFaCx5gc6kyu8UIRHwLEXsiKT7JTg=;
b=F6G2vXGvcyKiRglg2DHh4ouUVY+KZ5iGbnrVCZ1P+5h1d+OjWAQ166Er2kQJhRgAzGP9xpFhioNp3zOxfQdn5FZ0Mm5JOOc5HdVwai5qjGZ2T56Ad3hqjpkUAisb71SqVZYI8WFcYdpwKwixJps/UbdXCGQkB7PJFHENSGFOSCE=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender;
b=G8jc6X0t7+dAxDJcafJgMdajy8nORljCCPZ+FLjxQcbTjMymhi06lDN/gH59vkCcjVv8ft4T26mJj4c8Jc8TR1m+IH9D/xM8r74t2Y28HJiAzwy2xfa+mv1iT38cXPYGhIN1cqp7GnRq9KYx/AHUsosx2mnWfsw8GiAlFzicGMM=
Received: by 10.67.115.10 with SMTP id s10mr3116115ugm.89.1201239628812;
Thu, 24 Jan 2008 21:40:28 -0800 (PST)
Return-Path: <jarks...@gmail.com>
Received: from Probutanol.lan ( [91.153.207.11])
by mx.google.com with ESMTPS id n34sm2338341ugc.64.2008.01.24.21.40.27
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 24 Jan 2008 21:40:28 -0800 (PST)
Message-Id: <B8AC67E0-9EE3-4543-A8F3-E941CDB8B...@jlaine.net>
From: Jarkko Laine <jar...@jlaine.net>
To: low-pro@googlegroups.com
In-Reply-To: <f58d8dcb0801241734l66d81ad2t5db054dc198bb...@mail.gmail.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Apple Message framework v915)
Subject: Re: Adding a delete confirmation
Date: Fri, 25 Jan 2008 07:40:26 +0200
References: <8ced4378-7ea2-43f2-9ac8-05b4ad3ea...@x69g2000hsx.googlegroups.com> <f58d8dcb0801241734l66d81ad2t5db054dc198bb...@mail.gmail.com>
X-Mailer: Apple Mail (2.915)
Sender: Jarkko Laine <jarks...@gmail.com>
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)?
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi