Web Images Videos Maps News Shopping Google Mail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Adding a delete confirmation
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Jarkko Laine  
View profile   Translate to Translated (View Original)
 More options 25 Jan 2008, 05:40
From: Jarkko Laine <jar...@jlaine.net>
Date: Fri, 25 Jan 2008 07:40:26 +0200
Local: Fri 25 Jan 2008 05:40
Subject: Re: Adding a delete confirmation
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google