$("a.delete").live('click', function (){

 var url_id = $(this).attr("href");
 var div_id = url_id.split('/');
 var set_id = 'set_'+div_id[div_id.length-1];

 $('#'+set_id).addClass('pre_delete');

if (confirm('Delete?')) {
 $.ajax({
   type: "POST",
   url: url_id,
   success: function(){
    $('#' + set_id).fadeOut('slow', function () {
     $(this).remove();
    });
   }
  });

}
else {
 $('#'+set_id).removeClass('pre_delete');
}

return false;
 });



On Nov 9, 12:15 pm, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> My bad.
>
> Here is what I have so far.
>
> $("a.delete").live('click', function (){
>
>  var url_id = $(this).attr("href");
>  var div_id = url_id.split('/');  
>  var set_id = 'set_'+div_id[div_id.length-1];
>
>  $('#'+set_id).addClass('pre_delete');
>
>  $.ajax({
>    type: "POST",
>    url: url_id,
>    success: function(){
>     $('#' + set_id).fadeOut('slow', function () {
>      $(this).remove();
>     });
>    }
>   });
>  return false;
>  });
>
> I need to add in the confirm message. Above just adds the class when delete
> is clicked then deletes it. I would like the click delete add the class to
> the div then the confirm message appears. If they select yes then delete
> goes thru, if selected no then the added class gets removed.
>
> Thanks again
>
> Dave
>
> ________________________________
>
> From: Charlie Griefer [mailto:charlie.grie...@gmail.com]
> Sent: November-09-09 1:32 PM
> To: jquery-en@googlegroups.com
> Subject: Re: [jQuery] Confirm Delete
>
> On Mon, Nov 9, 2009 at 8:58 AM, Dave Maharaj :: WidePixels.com
>
> <d...@widepixels.com> wrote:
>
>         I am attempting to add a class to a div before deleting it. I just
> cant get the class  to remove if the user selects no.
>
>         Anyone have tips or a link with suggestions? I found the
> jquery.confirm.js script but unable to add a class to the element being
> deleted before confirm
>
> Hard to give guidance without seeing what code you are using now.
>
> Also, in your first paragraph you say "I just cant get the class to remove".
>
> In your second paragraph, you say you are "unable to add a class".  So not
> sure which it is.
>
> Either way, $('#myDiv').addClass('className'); or
> $('#myDiv').removeClass('className') should be all you need.
>
> If those aren't working out, seeing some code would go a long way towards
> helping to troubleshoot.
>
> --
> Charlie Grieferhttp://charlie.griefer.com/
>
> I have failed as much as I have succeeded. But I love my life. I love my
> wife. And I wish you my kind of success.

Reply via email to