views:

40

answers:

1

Hello guys,

I have a DataList containing a list of elements(ASP.Net app).

To delete an item i first used tha classic javascript confirmation.

As i found it ugly,i want to use a confirmation box plugin.

when i click OK==>Delete the item from DB(using a webservice)

But how can i update the DataList.

The situation is liek:

when u add a comment in Facebook.

delete link==>Conf box==>Delete==>Comments List update.

Thanks in advance

+1  A: 

Assumptions for this:

  • Each comment is in a div
  • Each comment's div has the id attribute set to something unique (based on comment id), for instance comment-{id}
    • When you confirm the deletion, it does an AJAX request to the webservice (not doing a postback).

When you click the delete button you can add the following to the end of the AJAX call (either as an onSuccess callback, or just directly after the AJAX call if you want it to happen immediately:

$('#comment-' + commentId).fadeOut('slow');

The commentId variable contains the id of the comment you're deleting (I assume you've got this otherwise you couldn't delete it). When concatenated with '#comment-' you have the unique id of the div containing the comment. You can select this with jQuery and then fade it out.

Michael Shimmins
Thanks you Michael.I will try your solution.
amourgh
@amourgh - make sure to accept the answer if it resolves your problem!
Nick Craver